musicbrainz-api 0.7.2 → 0.10.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.
Files changed (34) hide show
  1. package/.idea/$PRODUCT_WORKSPACE_FILE$ +1 -1
  2. package/.idea/misc.xml +6 -0
  3. package/.idea/modules.xml +7 -7
  4. package/.idea/vcs.xml +5 -5
  5. package/README.md +482 -290
  6. package/lib/digest-auth.d.ts +21 -21
  7. package/lib/digest-auth.js +82 -87
  8. package/lib/musicbrainz-api.d.ts +293 -156
  9. package/lib/musicbrainz-api.js +541 -390
  10. package/lib/musicbrainz.types.d.ts +585 -379
  11. package/lib/musicbrainz.types.js +16 -16
  12. package/lib/rate-limiter.d.ts +8 -8
  13. package/lib/rate-limiter.js +31 -31
  14. package/lib/xml/xml-isrc-list.d.ts +17 -17
  15. package/lib/xml/xml-isrc-list.js +22 -22
  16. package/lib/xml/xml-isrc.d.ts +10 -10
  17. package/lib/xml/xml-isrc.js +17 -17
  18. package/lib/xml/xml-metadata.d.ts +6 -6
  19. package/lib/xml/xml-metadata.js +29 -29
  20. package/lib/xml/xml-recording.d.ts +24 -24
  21. package/lib/xml/xml-recording.js +20 -20
  22. package/package.json +104 -98
  23. package/.idea/checkstyle-idea.xml +0 -16
  24. package/.idea/codeStyles/Project.xml +0 -38
  25. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  26. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  27. package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38_[Default_Changelist]/shelved.patch +0 -58
  28. package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38__Default_Changelist_.xml +0 -4
  29. package/.idea/shelf/Uncommitted_changes_before_rebase_[Default_Changelist]/shelved.patch +0 -738
  30. package/.idea/shelf/Uncommitted_changes_before_rebase_[Default_Changelist]1/shelved.patch +0 -0
  31. package/.idea/shelf/Uncommitted_changes_before_rebase__Default_Changelist_.xml +0 -4
  32. package/.idea/workspace.xml +0 -722
  33. package/etc/config.js +0 -32
  34. package/yarn-error.log +0 -3608
@@ -1,156 +1,293 @@
1
- export { XmlMetadata } from './xml/xml-metadata';
2
- export { XmlIsrc } from './xml/xml-isrc';
3
- export { XmlIsrcList } from './xml/xml-isrc-list';
4
- export { XmlRecording } from './xml/xml-recording';
5
- import { XmlMetadata } from './xml/xml-metadata';
6
- import * as mb from './musicbrainz.types';
7
- export * from './musicbrainz.types';
8
- /**
9
- * https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#Subqueries
10
- */
11
- export declare type Includes = 'artists' | 'releases' | 'recordings' | 'artist-credits' | 'isrcs' | 'url-rels' | 'release-groups' | 'aliases' | 'discids' | 'annotation' | 'media' | 'area-rels' | 'artist-rels' | 'event-rels' | 'instrument-rels' | 'label-rels' | 'place-rels' | 'recording-rels' | 'release-rels' | 'release-group-rels' | 'series-rels' | 'work-rels';
12
- export interface IFormData {
13
- [key: string]: string | number;
14
- }
15
- export interface IMusicBrainzConfig {
16
- botAccount?: {
17
- username: string;
18
- password: string;
19
- };
20
- baseUrl?: string;
21
- appName?: string;
22
- appVersion?: string;
23
- /**
24
- * HTTP Proxy
25
- */
26
- proxy?: string;
27
- /**
28
- * User e-mail address or application URL
29
- */
30
- appContactInfo?: string;
31
- }
32
- export interface ISessionInformation {
33
- csrf: {
34
- sessionKey: string;
35
- token: string;
36
- };
37
- loggedIn?: boolean;
38
- }
39
- export declare class MusicBrainzApi {
40
- private static escapeText;
41
- readonly config: IMusicBrainzConfig;
42
- private rateLimiter;
43
- private options;
44
- private session;
45
- static fetchCsrf(html: string): {
46
- sessionKey: string;
47
- token: string;
48
- };
49
- private static fetchValue;
50
- private getCookies;
51
- constructor(_config?: IMusicBrainzConfig);
52
- restGet<T>(relUrl: string, query?: {
53
- [key: string]: any;
54
- }, attempt?: number): Promise<T>;
55
- /**
56
- * Generic lookup function
57
- * @param entity
58
- * @param mbid
59
- * @param inc
60
- */
61
- getEntity<T>(entity: mb.EntityType, mbid: string, inc?: Includes[]): Promise<T>;
62
- /**
63
- * Lookup area
64
- * @param areaId Area MBID
65
- * @param inc Sub-queries
66
- */
67
- getArea(areaId: string, inc?: Includes[]): Promise<mb.IArea>;
68
- /**
69
- * Lookup artist
70
- * @param artistId Artist MBID
71
- * @param inc Sub-queries
72
- */
73
- getArtist(artistId: string, inc?: Includes[]): Promise<mb.IArtist>;
74
- /**
75
- * Lookup release
76
- * @param releaseId Release MBID
77
- * @param inc Include: artist-credits, labels, recordings, release-groups, media, discids, isrcs (with recordings)
78
- * ToDo: ['recordings', 'artists', 'artist-credits', 'isrcs', 'url-rels', 'release-groups']
79
- */
80
- getRelease(releaseId: string, inc?: Includes[]): Promise<mb.IRelease>;
81
- /**
82
- * Lookup release-group
83
- * @param releaseGroupId Release-group MBID
84
- * @param inc Include: ToDo
85
- */
86
- getReleaseGroup(releaseGroupId: string, inc?: Includes[]): Promise<mb.IReleaseGroup>;
87
- /**
88
- * Lookup work
89
- * @param workId Work MBID
90
- */
91
- getWork(workId: string): Promise<mb.IWork>;
92
- /**
93
- * Lookup label
94
- * @param labelId Label MBID
95
- */
96
- getLabel(labelId: string): Promise<mb.ILabel>;
97
- /**
98
- * Lookup recording
99
- * @param recordingId Label MBID
100
- * @param inc Include: artist-credits, isrcs
101
- */
102
- getRecording(recordingId: string, inc?: Includes[]): Promise<mb.IRecording>;
103
- postRecording(xmlMetadata: XmlMetadata): Promise<void>;
104
- post(entity: mb.EntityType, xmlMetadata: XmlMetadata): Promise<void>;
105
- login(): Promise<boolean>;
106
- /**
107
- * Logout
108
- */
109
- logout(): Promise<boolean>;
110
- /**
111
- * Submit entity
112
- * @param entity Entity type e.g. 'recording'
113
- * @param mbid
114
- * @param formData
115
- */
116
- editEntity(entity: mb.EntityType, mbid: string, formData: Record<string, any>): Promise<void>;
117
- /**
118
- * Set URL to recording
119
- * @param recording Recording to update
120
- * @param url2add URL to add to the recording
121
- * @param editNote Edit note
122
- */
123
- addUrlToRecording(recording: mb.IRecording, url2add: {
124
- linkTypeId: mb.LinkType;
125
- text: string;
126
- }, editNote?: string): Promise<void>;
127
- /**
128
- * Add ISRC to recording
129
- * @param recording Recording to update
130
- * @param isrc ISRC code to add
131
- * @param editNote Edit note
132
- */
133
- addIsrc(recording: mb.IRecording, isrc: string, editNote?: string): Promise<void>;
134
- /**
135
- * Search an entity using a search query
136
- * @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
137
- * @param entity e.g. 'recording'
138
- * @param query Arguments
139
- */
140
- search<T extends mb.ISearchResult>(entity: mb.EntityType, query: mb.ISearchQuery): Promise<T>;
141
- /**
142
- * Add Spotify-ID to MusicBrainz recording.
143
- * This function will automatically lookup the recording title, which is required to submit the recording URL
144
- * @param recording MBID of the recording
145
- * @param spotifyId Spotify ID
146
- * @param editNote Comment to add.
147
- */
148
- addSpotifyIdToRecording(recording: mb.IRecording, spotifyId: string, editNote: string): Promise<void>;
149
- searchArea(query: mb.ISearchQuery & mb.ILinkedEntitiesArea): Promise<mb.IAreaList>;
150
- searchArtist(query: mb.ISearchQuery & mb.ILinkedEntitiesArtist): Promise<mb.IArtistList>;
151
- searchRelease(query: mb.ISearchQuery & mb.ILinkedEntitiesRelease): Promise<mb.IReleaseList>;
152
- searchReleaseGroup(query: mb.ISearchQuery & mb.ILinkedEntitiesReleaseGroup): Promise<mb.IReleaseGroupList>;
153
- searchUrl(query: mb.ISearchQuery & mb.ILinkedEntitiesUrl): Promise<mb.IUrlList>;
154
- private getSession;
155
- }
156
- export declare function makeAndQueryString(keyValuePairs: IFormData): string;
1
+ export { XmlMetadata } from './xml/xml-metadata';
2
+ export { XmlIsrc } from './xml/xml-isrc';
3
+ export { XmlIsrcList } from './xml/xml-isrc-list';
4
+ export { XmlRecording } from './xml/xml-recording';
5
+ import { XmlMetadata } from './xml/xml-metadata';
6
+ import * as mb from './musicbrainz.types';
7
+ export * from './musicbrainz.types';
8
+ export declare 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';
9
+ export declare type SubQueryIncludes =
10
+ /**
11
+ * include discids for all media in the releases
12
+ */
13
+ 'discids'
14
+ /**
15
+ * include media for all releases, this includes the # of tracks on each medium and its format.
16
+ */
17
+ | 'media'
18
+ /**
19
+ * include isrcs for all recordings
20
+ */
21
+ | 'isrcs'
22
+ /**
23
+ * include artists credits for all releases and recordings
24
+ */
25
+ | 'artist-credits'
26
+ /**
27
+ * include only those releases where the artist appears on one of the tracks, only valid on artists in combination with `releases`
28
+ */
29
+ | 'various-artists';
30
+ export declare type MiscIncludes = 'aliases' | 'annotation' | 'tags' | 'genres' | 'ratings' | 'media';
31
+ export declare type AreaIncludes = MiscIncludes | RelationsIncludes;
32
+ export declare type ArtistIncludes = MiscIncludes | RelationsIncludes | 'recordings' | 'releases' | 'release-groups' | 'works';
33
+ export declare type CollectionIncludes = MiscIncludes | RelationsIncludes | 'user-collections';
34
+ export declare type EventIncludes = MiscIncludes | RelationsIncludes;
35
+ export declare type GenreIncludes = MiscIncludes;
36
+ export declare type InstrumentIncludes = MiscIncludes | RelationsIncludes;
37
+ export declare type LabelIncludes = MiscIncludes | RelationsIncludes | 'releases';
38
+ export declare type PlaceIncludes = MiscIncludes | RelationsIncludes;
39
+ export declare type RecordingIncludes = MiscIncludes | RelationsIncludes | SubQueryIncludes | 'artists' | 'releases' | 'isrcs';
40
+ export declare type ReleasesIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'collections' | 'labels' | 'recordings' | 'release-groups';
41
+ export declare type ReleaseGroupIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'releases';
42
+ export declare type SeriesIncludes = MiscIncludes | RelationsIncludes;
43
+ export declare type WorkIncludes = MiscIncludes | RelationsIncludes;
44
+ export declare type UrlIncludes = RelationsIncludes;
45
+ export interface IFormData {
46
+ [key: string]: string | number;
47
+ }
48
+ export interface IMusicBrainzConfig {
49
+ botAccount?: {
50
+ username: string;
51
+ password: string;
52
+ };
53
+ baseUrl?: string;
54
+ appName?: string;
55
+ appVersion?: string;
56
+ /**
57
+ * HTTP Proxy
58
+ */
59
+ proxy?: string;
60
+ /**
61
+ * User e-mail address or application URL
62
+ */
63
+ appContactInfo?: string;
64
+ }
65
+ export interface ISessionInformation {
66
+ csrf: {
67
+ sessionKey: string;
68
+ token: string;
69
+ };
70
+ loggedIn?: boolean;
71
+ }
72
+ export declare class MusicBrainzApi {
73
+ private static escapeText;
74
+ readonly config: IMusicBrainzConfig;
75
+ private rateLimiter;
76
+ private options;
77
+ private session;
78
+ static fetchCsrf(html: string): {
79
+ sessionKey: string;
80
+ token: string;
81
+ };
82
+ private static fetchValue;
83
+ private getCookies;
84
+ constructor(_config?: IMusicBrainzConfig);
85
+ restGet<T>(relUrl: string, query?: {
86
+ [key: string]: any;
87
+ }, attempt?: number): Promise<T>;
88
+ /**
89
+ * Generic lookup function
90
+ * @param entity
91
+ * @param mbid
92
+ * @param inc
93
+ */
94
+ lookupEntity<T, I extends string = never>(entity: mb.EntityType, mbid: string, inc?: I[]): Promise<T>;
95
+ /**
96
+ * Lookup area
97
+ * @param areaId Area MBID
98
+ * @param inc Sub-queries
99
+ */
100
+ lookupArea(areaId: string, inc?: AreaIncludes[]): Promise<mb.IArea>;
101
+ /**
102
+ * Lookup artist
103
+ * @param artistId Artist MBID
104
+ * @param inc Sub-queries
105
+ */
106
+ lookupArtist(artistId: string, inc?: ArtistIncludes[]): Promise<mb.IArtist>;
107
+ /**
108
+ * Lookup collection
109
+ * @param collectionId Collection MBID
110
+ * @param inc List of additional information to be included about the entity. Any of the entities directly linked to the entity can be included.
111
+ */
112
+ lookupCollection(collectionId: string, inc?: ArtistIncludes[]): Promise<mb.ICollection>;
113
+ /**
114
+ * Lookup instrument
115
+ * @param artistId Instrument MBID
116
+ * @param inc Sub-queries
117
+ */
118
+ lookupInstrument(instrumentId: string, inc?: InstrumentIncludes[]): Promise<mb.IInstrument>;
119
+ /**
120
+ * Lookup label
121
+ * @param labelId Area MBID
122
+ * @param inc Sub-queries
123
+ */
124
+ lookupLabel(labelId: string, inc?: LabelIncludes[]): Promise<mb.ILabel>;
125
+ /**
126
+ * Lookup place
127
+ * @param placeId Area MBID
128
+ * @param inc Sub-queries
129
+ */
130
+ lookupPlace(placeId: string, inc?: PlaceIncludes[]): Promise<mb.IPlace>;
131
+ /**
132
+ * Lookup release
133
+ * @param releaseId Release MBID
134
+ * @param inc Include: artist-credits, labels, recordings, release-groups, media, discids, isrcs (with recordings)
135
+ * ToDo: ['recordings', 'artists', 'artist-credits', 'isrcs', 'url-rels', 'release-groups']
136
+ */
137
+ lookupRelease(releaseId: string, inc?: ReleasesIncludes[]): Promise<mb.IRelease>;
138
+ /**
139
+ * Lookup release-group
140
+ * @param releaseGroupId Release-group MBID
141
+ * @param inc Include: ToDo
142
+ */
143
+ lookupReleaseGroup(releaseGroupId: string, inc?: ReleaseGroupIncludes[]): Promise<mb.IReleaseGroup>;
144
+ /**
145
+ * Lookup recording
146
+ * @param recordingId Label MBID
147
+ * @param inc Include: artist-credits, isrcs
148
+ */
149
+ lookupRecording(recordingId: string, inc?: RecordingIncludes[]): Promise<mb.IRecording>;
150
+ /**
151
+ * Lookup work
152
+ * @param workId Work MBID
153
+ */
154
+ lookupWork(workId: string, inc?: WorkIncludes[]): Promise<mb.IWork>;
155
+ /**
156
+ * Lookup URL
157
+ * @param urlId URL MBID
158
+ */
159
+ lookupUrl(urlId: string, inc?: UrlIncludes[]): Promise<mb.IUrl>;
160
+ /**
161
+ * Lookup Event
162
+ * @param eventId Event MBID
163
+ * @param eventIncludes List of sub-queries to enable
164
+ */
165
+ lookupEvent(eventId: string, eventIncludes?: EventIncludes[]): Promise<mb.IEvent>;
166
+ /**
167
+ * Generic browse function
168
+ * https://wiki.musicbrainz.org/Development/JSON_Web_Service#Browse_Requests
169
+ * @param entity MusicBrainz entity
170
+ * @param query Query, like: {<entity>: <MBID:}
171
+ */
172
+ browseEntity<T>(entity: mb.EntityType, query?: {
173
+ [key: string]: any;
174
+ }): Promise<T>;
175
+ /**
176
+ * Browse areas
177
+ * @param query Query, like: {<entity>: <MBID:}
178
+ */
179
+ browseAreas(query?: mb.IBrowseAreasQuery): Promise<mb.IBrowseAreasResult>;
180
+ /**
181
+ * Browse artists
182
+ * @param query Query, like: {<entity>: <MBID:}
183
+ */
184
+ browseArtists(query?: mb.IBrowseArtistsQuery): Promise<mb.IBrowseArtistsResult>;
185
+ /**
186
+ * Browse collections
187
+ * @param query Query, like: {<entity>: <MBID:}
188
+ */
189
+ browseCollections(query?: mb.IBrowseCollectionsQuery): Promise<mb.IBrowseCollectionsResult>;
190
+ /**
191
+ * Browse events
192
+ * @param query Query, like: {<entity>: <MBID:}
193
+ */
194
+ browseEvents(query?: mb.IBrowseEventsQuery): Promise<mb.IBrowseEventsResult>;
195
+ /**
196
+ * Browse instruments
197
+ * @param query Query, like: {<entity>: <MBID:}
198
+ */
199
+ browseInstruments(query?: mb.IBrowseInstrumentsQuery): Promise<mb.IBrowseInstrumentsResult>;
200
+ /**
201
+ * Browse labels
202
+ * @param query Query, like: {<entity>: <MBID:}
203
+ */
204
+ browseLabels(query?: mb.IBrowseLabelsQuery): Promise<mb.IBrowseLabelsResult>;
205
+ /**
206
+ * Browse places
207
+ * @param query Query, like: {<entity>: <MBID:}
208
+ */
209
+ browsePlaces(query?: mb.IBrowsePlacesQuery): Promise<mb.IBrowsePlacesResult>;
210
+ /**
211
+ * Browse recordings
212
+ * @param query Query, like: {<entity>: <MBID:}
213
+ */
214
+ browseRecordings(query?: mb.IBrowseRecordingsQuery): Promise<mb.IBrowseRecordingsResult>;
215
+ /**
216
+ * Browse releases
217
+ * @param query Query, like: {<entity>: <MBID:}
218
+ */
219
+ browseReleases(query?: mb.IBrowseReleasesQuery): Promise<mb.IBrowseReleasesResult>;
220
+ /**
221
+ * Browse release-groups
222
+ * @param query Query, like: {<entity>: <MBID:}
223
+ */
224
+ browseReleaseGroups(query?: mb.IReleaseGroupsQuery): Promise<mb.IBrowseReleaseGroupsResult>;
225
+ /**
226
+ * Browse series
227
+ * @param query Query, like: {<entity>: <MBID:}
228
+ */
229
+ browseSeries(query?: mb.IBrowseSeriesQuery): Promise<mb.IBrowseSeriesResult>;
230
+ /**
231
+ * Browse works
232
+ * @param query Query, like: {<entity>: <MBID:}
233
+ */
234
+ browseWorks(query?: mb.IBrowseWorksQuery): Promise<mb.IBrowseWorksResult>;
235
+ /**
236
+ * Browse URLs
237
+ * @param query Query, like: {<entity>: <MBID:}
238
+ */
239
+ browseUrls(query?: mb.IBrowseUrlsQuery): Promise<mb.IUrl>;
240
+ postRecording(xmlMetadata: XmlMetadata): Promise<void>;
241
+ post(entity: mb.EntityType, xmlMetadata: XmlMetadata): Promise<void>;
242
+ login(): Promise<boolean>;
243
+ /**
244
+ * Logout
245
+ */
246
+ logout(): Promise<boolean>;
247
+ /**
248
+ * Submit entity
249
+ * @param entity Entity type e.g. 'recording'
250
+ * @param mbid
251
+ * @param formData
252
+ */
253
+ editEntity(entity: mb.EntityType, mbid: string, formData: Record<string, any>): Promise<void>;
254
+ /**
255
+ * Set URL to recording
256
+ * @param recording Recording to update
257
+ * @param url2add URL to add to the recording
258
+ * @param editNote Edit note
259
+ */
260
+ addUrlToRecording(recording: mb.IRecording, url2add: {
261
+ linkTypeId: mb.LinkType;
262
+ text: string;
263
+ }, editNote?: string): Promise<void>;
264
+ /**
265
+ * Add ISRC to recording
266
+ * @param recording Recording to update
267
+ * @param isrc ISRC code to add
268
+ * @param editNote Edit note
269
+ */
270
+ addIsrc(recording: mb.IRecording, isrc: string, editNote?: string): Promise<void>;
271
+ /**
272
+ * Search an entity using a search query
273
+ * @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
274
+ * @param entity e.g. 'recording'
275
+ * @param query Arguments
276
+ */
277
+ search<T extends mb.ISearchResult, I extends string = never>(entity: mb.EntityType, query: mb.ISearchQuery<I>): Promise<T>;
278
+ /**
279
+ * Add Spotify-ID to MusicBrainz recording.
280
+ * This function will automatically lookup the recording title, which is required to submit the recording URL
281
+ * @param recording MBID of the recording
282
+ * @param spotifyId Spotify ID
283
+ * @param editNote Comment to add.
284
+ */
285
+ addSpotifyIdToRecording(recording: mb.IRecording, spotifyId: string, editNote: string): Promise<void>;
286
+ searchArea(query: mb.ISearchQuery<AreaIncludes> & mb.ILinkedEntitiesArea): Promise<mb.IAreaList>;
287
+ searchArtist(query: mb.ISearchQuery<ArtistIncludes> & mb.ILinkedEntitiesArtist): Promise<mb.IArtistList>;
288
+ searchRelease(query: mb.ISearchQuery<ReleasesIncludes> & mb.ILinkedEntitiesRelease): Promise<mb.IReleaseList>;
289
+ searchReleaseGroup(query: mb.ISearchQuery<ReleaseGroupIncludes> & mb.ILinkedEntitiesReleaseGroup): Promise<mb.IReleaseGroupList>;
290
+ searchUrl(query: mb.ISearchQuery<UrlIncludes> & mb.ILinkedEntitiesUrl): Promise<mb.IUrlList>;
291
+ private getSession;
292
+ }
293
+ export declare function makeAndQueryString(keyValuePairs: IFormData): string;