musicbrainz-api 0.12.0 → 0.14.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 +33 -139
- package/lib/coverartarchive-api.js +3 -7
- package/lib/digest-auth.js +4 -8
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -18
- package/lib/musicbrainz-api.d.ts +54 -170
- package/lib/musicbrainz-api.js +81 -312
- package/lib/musicbrainz.types.d.ts +14 -6
- package/lib/musicbrainz.types.js +2 -5
- package/lib/xml/xml-isrc-list.d.ts +1 -1
- package/lib/xml/xml-isrc-list.js +3 -7
- package/lib/xml/xml-isrc.js +1 -5
- package/lib/xml/xml-metadata.d.ts +1 -1
- package/lib/xml/xml-metadata.js +4 -8
- package/lib/xml/xml-recording.d.ts +1 -1
- package/lib/xml/xml-recording.js +3 -7
- package/package.json +20 -19
- package/lib/rate-limiter.d.ts +0 -8
- package/lib/rate-limiter.js +0 -34
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musicbrainz-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "MusicBrainz API client for reading and submitting metadata",
|
|
5
|
-
"
|
|
6
|
-
"types": "lib/index",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*.js",
|
|
9
|
+
"lib/**/*.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
7
12
|
"author": {
|
|
8
13
|
"name": "Borewit",
|
|
9
14
|
"url": "https://github.com/Borewit"
|
|
@@ -31,7 +36,7 @@
|
|
|
31
36
|
"license": "MIT",
|
|
32
37
|
"private": false,
|
|
33
38
|
"engines": {
|
|
34
|
-
"node": "
|
|
39
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
35
40
|
},
|
|
36
41
|
"repository": {
|
|
37
42
|
"type": "git",
|
|
@@ -45,11 +50,12 @@
|
|
|
45
50
|
"@types/request-promise-native": "^1.0.17",
|
|
46
51
|
"@types/uuid": "^9.0.0",
|
|
47
52
|
"caseless": "^0.12.0",
|
|
48
|
-
"debug": "^4.
|
|
49
|
-
"got": "^
|
|
53
|
+
"debug": "^4.3.4",
|
|
54
|
+
"got": "^13.0.0",
|
|
50
55
|
"http-status-codes": "^2.1.4",
|
|
51
56
|
"json-stringify-safe": "^5.0.1",
|
|
52
57
|
"jsontoxml": "^1.0.1",
|
|
58
|
+
"rate-limit-threshold": "^0.1.5",
|
|
53
59
|
"source-map-support": "^0.5.16",
|
|
54
60
|
"tough-cookie": "^4.1.3",
|
|
55
61
|
"uuid": "^9.0.0"
|
|
@@ -57,31 +63,26 @@
|
|
|
57
63
|
"devDependencies": {
|
|
58
64
|
"@types/chai": "^4.3.0",
|
|
59
65
|
"@types/jsontoxml": "^1.0.5",
|
|
60
|
-
"@types/mocha": "^
|
|
66
|
+
"@types/mocha": "^10.0.4",
|
|
61
67
|
"@types/node": "^20.8.10",
|
|
62
68
|
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
|
63
69
|
"@typescript-eslint/parser": "^5.13.0",
|
|
70
|
+
"c8": "^8.0.1",
|
|
64
71
|
"chai": "^4.2.0",
|
|
65
72
|
"del-cli": "^5.0.0",
|
|
66
73
|
"eslint": "^8.10.0",
|
|
67
|
-
"eslint-config-prettier": "^
|
|
74
|
+
"eslint-config-prettier": "^9.0.0",
|
|
68
75
|
"eslint-import-resolver-typescript": "^3.3.0",
|
|
69
76
|
"eslint-plugin-import": "^2.25.4",
|
|
70
77
|
"eslint-plugin-jsdoc": "^46.8.2",
|
|
71
78
|
"eslint-plugin-node": "^11.1.0",
|
|
72
|
-
"eslint-plugin-unicorn": "^
|
|
73
|
-
"mocha": "^
|
|
74
|
-
"
|
|
75
|
-
"remark-cli": "^11.0.0",
|
|
79
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
80
|
+
"mocha": "^10.1.0",
|
|
81
|
+
"remark-cli": "^12.0.0",
|
|
76
82
|
"remark-preset-lint-recommended": "^6.1.2",
|
|
77
83
|
"ts-node": "^10.0.0",
|
|
78
|
-
"tslint": "^6.1.1",
|
|
79
84
|
"typescript": "^5.0.2"
|
|
80
85
|
},
|
|
81
|
-
"files": [
|
|
82
|
-
"lib/**/*.js",
|
|
83
|
-
"lib/**/*.d.ts"
|
|
84
|
-
],
|
|
85
86
|
"scripts": {
|
|
86
87
|
"clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.js test/**/*.js.map",
|
|
87
88
|
"compile-lib": "tsc -p lib",
|
|
@@ -90,10 +91,10 @@
|
|
|
90
91
|
"eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts test/**/*.ts",
|
|
91
92
|
"lint-md": "remark -u preset-lint-recommended .",
|
|
92
93
|
"lint": "npm run lint-md && npm run eslint",
|
|
93
|
-
"test": "mocha
|
|
94
|
+
"test": "mocha",
|
|
94
95
|
"build": "npm run clean && npm run compile",
|
|
95
96
|
"start": "npm-run-all compile lint cover-test",
|
|
96
|
-
"test-coverage": "
|
|
97
|
+
"test-coverage": "c8 npm run test",
|
|
97
98
|
"send-codacy": "nyc report --reporter=text-lcov | codacy-coverage"
|
|
98
99
|
},
|
|
99
100
|
"nyc": {
|
package/lib/rate-limiter.d.ts
DELETED
package/lib/rate-limiter.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RateLimiter = void 0;
|
|
4
|
-
const debug_1 = require("debug");
|
|
5
|
-
const debug = (0, debug_1.default)('musicbrainz-api:rate-limiter');
|
|
6
|
-
class RateLimiter {
|
|
7
|
-
static sleep(ms) {
|
|
8
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
9
|
-
}
|
|
10
|
-
constructor(maxCalls, period) {
|
|
11
|
-
this.maxCalls = maxCalls;
|
|
12
|
-
this.queue = [];
|
|
13
|
-
debug(`Rate limiter initialized with max ${maxCalls} calls in ${period} seconds.`);
|
|
14
|
-
this.period = 1000 * period;
|
|
15
|
-
}
|
|
16
|
-
async limit() {
|
|
17
|
-
let now = new Date().getTime();
|
|
18
|
-
const t0 = now - (this.period);
|
|
19
|
-
while (this.queue.length > 0 && this.queue[0] < t0) {
|
|
20
|
-
this.queue.shift();
|
|
21
|
-
}
|
|
22
|
-
// debug(`Current rate is ${this.queue.length} per ${this.period / 1000} sec`);
|
|
23
|
-
if (this.queue.length >= this.maxCalls) {
|
|
24
|
-
const delay = this.queue[0] + this.period - now;
|
|
25
|
-
debug(`Client side rate limiter activated: cool down for ${delay / 1000} s...`);
|
|
26
|
-
return RateLimiter.sleep(delay);
|
|
27
|
-
}
|
|
28
|
-
now = new Date().getTime();
|
|
29
|
-
this.queue.push(now);
|
|
30
|
-
// const ratePerSec = 1000 * this.queue.length / (now - this.queue[0]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.RateLimiter = RateLimiter;
|
|
34
|
-
//# sourceMappingURL=rate-limiter.js.map
|