musicbrainz-api
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -10,8 +10,2 @@ "use strict"; | ||
class DigestAuth { | ||
constructor(credentials) { | ||
this.credentials = credentials; | ||
this.hasAuth = false; | ||
this.sentAuth = false; | ||
this.bearerToken = null; | ||
} | ||
/** | ||
@@ -29,2 +23,8 @@ * RFC 2617: handle both MD5 and MD5-sess algorithms. | ||
} | ||
constructor(credentials) { | ||
this.credentials = credentials; | ||
this.hasAuth = false; | ||
this.sentAuth = false; | ||
this.bearerToken = null; | ||
} | ||
digest(method, path, authHeader) { | ||
@@ -31,0 +31,0 @@ // TODO: More complete implementation of RFC 2617. |
@@ -8,4 +8,4 @@ export { XmlMetadata } from './xml/xml-metadata'; | ||
export * from './musicbrainz.types'; | ||
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'; | ||
export declare type SubQueryIncludes = | ||
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'; | ||
export type SubQueryIncludes = | ||
/** | ||
@@ -31,17 +31,17 @@ * include discids for all media in the releases | ||
| 'various-artists'; | ||
export declare type MiscIncludes = 'aliases' | 'annotation' | 'tags' | 'genres' | 'ratings' | 'media'; | ||
export declare type AreaIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type ArtistIncludes = MiscIncludes | RelationsIncludes | 'recordings' | 'releases' | 'release-groups' | 'works'; | ||
export declare type CollectionIncludes = MiscIncludes | RelationsIncludes | 'user-collections'; | ||
export declare type EventIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type GenreIncludes = MiscIncludes; | ||
export declare type InstrumentIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type LabelIncludes = MiscIncludes | RelationsIncludes | 'releases'; | ||
export declare type PlaceIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type RecordingIncludes = MiscIncludes | RelationsIncludes | SubQueryIncludes | 'artists' | 'releases' | 'isrcs'; | ||
export declare type ReleasesIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'collections' | 'labels' | 'recordings' | 'release-groups'; | ||
export declare type ReleaseGroupIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'releases'; | ||
export declare type SeriesIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type WorkIncludes = MiscIncludes | RelationsIncludes; | ||
export declare type UrlIncludes = RelationsIncludes; | ||
export type MiscIncludes = 'aliases' | 'annotation' | 'tags' | 'genres' | 'ratings' | 'media'; | ||
export type AreaIncludes = MiscIncludes | RelationsIncludes; | ||
export type ArtistIncludes = MiscIncludes | RelationsIncludes | 'recordings' | 'releases' | 'release-groups' | 'works'; | ||
export type CollectionIncludes = MiscIncludes | RelationsIncludes | 'user-collections'; | ||
export type EventIncludes = MiscIncludes | RelationsIncludes; | ||
export type GenreIncludes = MiscIncludes; | ||
export type InstrumentIncludes = MiscIncludes | RelationsIncludes; | ||
export type LabelIncludes = MiscIncludes | RelationsIncludes | 'releases'; | ||
export type PlaceIncludes = MiscIncludes | RelationsIncludes; | ||
export type RecordingIncludes = MiscIncludes | RelationsIncludes | SubQueryIncludes | 'artists' | 'releases' | 'isrcs'; | ||
export type ReleasesIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'collections' | 'labels' | 'recordings' | 'release-groups'; | ||
export type ReleaseGroupIncludes = MiscIncludes | SubQueryIncludes | RelationsIncludes | 'artists' | 'releases'; | ||
export type SeriesIncludes = MiscIncludes | RelationsIncludes; | ||
export type WorkIncludes = MiscIncludes | RelationsIncludes; | ||
export type UrlIncludes = RelationsIncludes; | ||
export interface IFormData { | ||
@@ -48,0 +48,0 @@ [key: string]: string | number; |
@@ -40,19 +40,2 @@ "use strict"; | ||
class MusicBrainzApi { | ||
constructor(_config) { | ||
this.config = { | ||
baseUrl: 'https://musicbrainz.org' | ||
}; | ||
Object.assign(this.config, _config); | ||
const cookieJar = new tough.CookieJar(); | ||
this.getCookies = (0, util_1.promisify)(cookieJar.getCookies.bind(cookieJar)); | ||
this.options = { | ||
prefixUrl: this.config.baseUrl, | ||
timeout: 20 * 1000, | ||
headers: { | ||
'User-Agent': `${this.config.appName}/${this.config.appVersion} ( ${this.config.appContactInfo} )` | ||
}, | ||
cookieJar | ||
}; | ||
this.rateLimiter = new rate_limiter_1.RateLimiter(60, 50); | ||
} | ||
static escapeText(text) { | ||
@@ -105,2 +88,19 @@ let str = ''; | ||
} | ||
constructor(_config) { | ||
this.config = { | ||
baseUrl: 'https://musicbrainz.org' | ||
}; | ||
Object.assign(this.config, _config); | ||
const cookieJar = new tough.CookieJar(); | ||
this.getCookies = (0, util_1.promisify)(cookieJar.getCookies.bind(cookieJar)); | ||
this.options = { | ||
prefixUrl: this.config.baseUrl, | ||
timeout: 20 * 1000, | ||
headers: { | ||
'User-Agent': `${this.config.appName}/${this.config.appVersion} ( ${this.config.appContactInfo} )` | ||
}, | ||
cookieJar | ||
}; | ||
this.rateLimiter = new rate_limiter_1.RateLimiter(60, 50); | ||
} | ||
async restGet(relUrl, query = {}, attempt = 1) { | ||
@@ -107,0 +107,0 @@ query.fmt = 'json'; |
@@ -84,3 +84,3 @@ import DateTimeFormat = Intl.DateTimeFormat; | ||
} | ||
export declare type ReleaseQuality = 'normal'; | ||
export type ReleaseQuality = 'normal'; | ||
export interface IRelease extends IEntity { | ||
@@ -113,3 +113,3 @@ title: string; | ||
} | ||
export declare type MediaFormatType = 'Digital Media'; | ||
export type MediaFormatType = 'Digital Media'; | ||
export interface IRecording extends IEntity { | ||
@@ -190,3 +190,3 @@ video: boolean; | ||
} | ||
export declare type RelationDirection = 'backward' | 'forward'; | ||
export type RelationDirection = 'backward' | 'forward'; | ||
export interface IRelation { | ||
@@ -243,4 +243,4 @@ 'attribute-ids': any; | ||
*/ | ||
export declare type EntityType = 'area' | 'artist' | 'collection' | 'event' | 'instrument' | 'label' | 'place' | 'recording' | 'release' | 'release-group' | 'series' | 'work' | 'url'; | ||
export declare 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'; | ||
export type EntityType = 'area' | 'artist' | 'collection' | 'event' | 'instrument' | 'label' | 'place' | 'recording' | 'release' | 'release-group' | 'series' | 'work' | 'url'; | ||
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'; | ||
export declare enum LinkType { | ||
@@ -576,3 +576,3 @@ license = 302, | ||
export interface IBrowseReleaseGroupsResult { | ||
'release-groups': IReleaseGroupsQuery[]; | ||
'release-groups': IReleaseGroup[]; | ||
'release-group-count': number; | ||
@@ -579,0 +579,0 @@ 'release-group-offset': number; |
@@ -7,2 +7,5 @@ "use strict"; | ||
class RateLimiter { | ||
static sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
constructor(period, maxCalls) { | ||
@@ -13,5 +16,2 @@ this.maxCalls = maxCalls; | ||
} | ||
static sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
async limit() { | ||
@@ -18,0 +18,0 @@ let now = new Date().getTime(); |
{ | ||
"name": "musicbrainz-api", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "MusicBrainz API client for reading and submitting metadata", | ||
@@ -49,3 +49,3 @@ "main": "lib/musicbrainz-api", | ||
"tough-cookie": "^4.0.0", | ||
"uuid": "^8.3.2" | ||
"uuid": "^9.0.0" | ||
}, | ||
@@ -66,3 +66,3 @@ "devDependencies": { | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-unicorn": "^43.0.2", | ||
"eslint-plugin-unicorn": "^44.0.2", | ||
"mocha": "^9.0.1", | ||
@@ -69,0 +69,0 @@ "nyc": "^15.0.0", |
@@ -97,3 +97,3 @@ [![Node.js CI](https://github.com/Borewit/musicbrainz-api/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/musicbrainz-api/actions/workflows/nodejs-ci.yml) | ||
```js | ||
const artist = await mbApi.lookupEntity('artist', {query: 'ab2528d9-719f-4261-8098-21849222a0f2'}); | ||
const artist = await mbApi.lookupEntity('artist', 'ab2528d9-719f-4261-8098-21849222a0f2'); | ||
``` | ||
@@ -104,3 +104,3 @@ | ||
```js | ||
const area = await mbApi.lookupArea({query: 'ab2528d9-719f-4261-8098-21849222a0f2'}); | ||
const area = await mbApi.lookupArea('ab2528d9-719f-4261-8098-21849222a0f2'); | ||
``` | ||
@@ -113,3 +113,3 @@ | ||
```js | ||
const artist = await mbApi.lookupArtist({query: 'ab2528d9-719f-4261-8098-21849222a0f2'}); | ||
const artist = await mbApi.lookupArtist('ab2528d9-719f-4261-8098-21849222a0f2'); | ||
``` | ||
@@ -122,3 +122,3 @@ | ||
```js | ||
const artist = await mbApi.lookupInstrument({query: 'b3eac5f9-7859-4416-ac39-7154e2e8d348'}); | ||
const instrument = await mbApi.lookupInstrument('b3eac5f9-7859-4416-ac39-7154e2e8d348'); | ||
``` | ||
@@ -131,3 +131,3 @@ | ||
```js | ||
const artist = await mbApi.lookupInstrument({query: '25dda9f9-f069-4898-82f0-59330a106c7f'}); | ||
const label = await mbApi.lookupLabel('25dda9f9-f069-4898-82f0-59330a106c7f'); | ||
``` | ||
@@ -138,3 +138,3 @@ | ||
```js | ||
const artist = await mbApi.lookupPlace({query: 'e6cfb74d-d69b-44c3-b890-1b3f509816e4'}); | ||
const place = await mbApi.lookupPlace('e6cfb74d-d69b-44c3-b890-1b3f509816e4'); | ||
``` | ||
@@ -151,3 +151,3 @@ | ||
```js | ||
const artist = await mbApi.lookupRecording({query: '16afa384-174e-435e-bfa3-5591accda31c'}, ['artists', 'url-rels']); | ||
const recording = await mbApi.lookupRecording('16afa384-174e-435e-bfa3-5591accda31c', ['artists', 'url-rels']); | ||
``` | ||
@@ -157,3 +157,3 @@ | ||
```js | ||
const release = await mbApi.lookupRelease({query: '976e0677-a480-4a5e-a177-6a86c1900bbf'}, ['artists', 'url-rels']); | ||
const release = await mbApi.lookupRelease('976e0677-a480-4a5e-a177-6a86c1900bbf', ['artists', 'url-rels']); | ||
``` | ||
@@ -163,3 +163,3 @@ | ||
```js | ||
const releaseGroup = await mbApi.lookupReleaseGroup({query: '19099ea5-3600-4154-b482-2ec68815883e'}); | ||
const releaseGroup = await mbApi.lookupReleaseGroup('19099ea5-3600-4154-b482-2ec68815883e'); | ||
``` | ||
@@ -169,3 +169,3 @@ | ||
```js | ||
const work = await mbApi.lookupWork({query: 'b2aa02f4-6c95-43be-a426-aedb9f9a3805'}); | ||
const work = await mbApi.lookupWork('b2aa02f4-6c95-43be-a426-aedb9f9a3805'); | ||
``` | ||
@@ -175,10 +175,5 @@ | ||
```js | ||
const url = await mbApi.lookupUrl({query: 'c69556a6-7ded-4c54-809c-afb45a1abe7d'}); | ||
const url = await mbApi.lookupUrl('c69556a6-7ded-4c54-809c-afb45a1abe7d'); | ||
``` | ||
### Lookup URL | ||
```js | ||
const url = await mbApi.lookupUrl({query: 'c69556a6-7ded-4c54-809c-afb45a1abe7d'}); | ||
``` | ||
## Browse entities | ||
@@ -185,0 +180,0 @@ |
24
78450
478
+ Addeduuid@9.0.1(transitive)
- Removeduuid@8.3.2(transitive)
Updateduuid@^9.0.0