musicbrainz-api 0.5.2 → 0.7.2

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 (35) hide show
  1. package/.idea/$CACHE_FILE$ +6 -0
  2. package/.idea/$PRODUCT_WORKSPACE_FILE$ +19 -0
  3. package/.idea/checkstyle-idea.xml +16 -0
  4. package/.idea/codeStyles/Project.xml +38 -0
  5. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/misc.xml +6 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38_[Default_Changelist]/shelved.patch +58 -0
  10. package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38__Default_Changelist_.xml +4 -0
  11. package/.idea/shelf/Uncommitted_changes_before_rebase_[Default_Changelist]/shelved.patch +738 -0
  12. package/.idea/shelf/Uncommitted_changes_before_rebase_[Default_Changelist]1/shelved.patch +0 -0
  13. package/.idea/shelf/Uncommitted_changes_before_rebase__Default_Changelist_.xml +4 -0
  14. package/.idea/vcs.xml +6 -0
  15. package/.idea/workspace.xml +722 -0
  16. package/README.md +290 -287
  17. package/etc/config.js +32 -0
  18. package/lib/digest-auth.d.ts +21 -21
  19. package/lib/digest-auth.js +87 -86
  20. package/lib/musicbrainz-api.d.ts +156 -140
  21. package/lib/musicbrainz-api.js +390 -372
  22. package/lib/musicbrainz.types.d.ts +379 -252
  23. package/lib/musicbrainz.types.js +16 -15
  24. package/lib/rate-limiter.d.ts +8 -8
  25. package/lib/rate-limiter.js +31 -30
  26. package/lib/xml/xml-isrc-list.d.ts +17 -17
  27. package/lib/xml/xml-isrc-list.js +22 -21
  28. package/lib/xml/xml-isrc.d.ts +10 -10
  29. package/lib/xml/xml-isrc.js +17 -16
  30. package/lib/xml/xml-metadata.d.ts +6 -6
  31. package/lib/xml/xml-metadata.js +29 -28
  32. package/lib/xml/xml-recording.d.ts +24 -24
  33. package/lib/xml/xml-recording.js +20 -19
  34. package/package.json +98 -99
  35. package/yarn-error.log +3608 -0
@@ -1,8 +1,8 @@
1
- export declare class RateLimiter {
2
- private maxCalls;
3
- static sleep(ms: any): Promise<void>;
4
- queue: number[];
5
- private readonly period;
6
- constructor(period: number, maxCalls: number);
7
- limit(): Promise<void>;
8
- }
1
+ export declare class RateLimiter {
2
+ private maxCalls;
3
+ static sleep(ms: any): Promise<void>;
4
+ queue: number[];
5
+ private readonly period;
6
+ constructor(period: number, maxCalls: number);
7
+ limit(): Promise<void>;
8
+ }
@@ -1,31 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Debug = require("debug");
4
- const debug = Debug('musicbrainz-api:rate-limiter');
5
- class RateLimiter {
6
- constructor(period, maxCalls) {
7
- this.maxCalls = maxCalls;
8
- this.queue = [];
9
- this.period = 1000 * period;
10
- }
11
- static sleep(ms) {
12
- return new Promise(resolve => setTimeout(resolve, ms));
13
- }
14
- async limit() {
15
- let now = new Date().getTime();
16
- const t0 = now - (this.period);
17
- while (this.queue.length > 0 && this.queue[0] < t0) {
18
- this.queue.shift();
19
- }
20
- if (this.queue.length >= this.maxCalls) {
21
- const delay = this.queue[0] + this.period - now;
22
- debug(`Client side rate limiter activated: cool down for ${delay / 1000} s...`);
23
- return RateLimiter.sleep(delay);
24
- }
25
- now = new Date().getTime();
26
- this.queue.push(now);
27
- // const ratePerSec = 1000 * this.queue.length / (now - this.queue[0]);
28
- }
29
- }
30
- exports.RateLimiter = RateLimiter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimiter = void 0;
4
+ const Debug = require("debug");
5
+ const debug = Debug('musicbrainz-api:rate-limiter');
6
+ class RateLimiter {
7
+ constructor(period, maxCalls) {
8
+ this.maxCalls = maxCalls;
9
+ this.queue = [];
10
+ this.period = 1000 * period;
11
+ }
12
+ static sleep(ms) {
13
+ return new Promise(resolve => setTimeout(resolve, ms));
14
+ }
15
+ async limit() {
16
+ let now = new Date().getTime();
17
+ const t0 = now - (this.period);
18
+ while (this.queue.length > 0 && this.queue[0] < t0) {
19
+ this.queue.shift();
20
+ }
21
+ if (this.queue.length >= this.maxCalls) {
22
+ const delay = this.queue[0] + this.period - now;
23
+ debug(`Client side rate limiter activated: cool down for ${delay / 1000} s...`);
24
+ return RateLimiter.sleep(delay);
25
+ }
26
+ now = new Date().getTime();
27
+ this.queue.push(now);
28
+ // const ratePerSec = 1000 * this.queue.length / (now - this.queue[0]);
29
+ }
30
+ }
31
+ exports.RateLimiter = RateLimiter;
31
32
  //# sourceMappingURL=rate-limiter.js.map
@@ -1,17 +1,17 @@
1
- import { XmlIsrc } from './xml-isrc';
2
- export declare class XmlIsrcList {
3
- items: XmlIsrc[];
4
- pushIsrc(isrc: string): void;
5
- toXml(): {
6
- name: string;
7
- attrs: {
8
- count: number;
9
- };
10
- children: {
11
- name: string;
12
- attrs: {
13
- id: string;
14
- };
15
- }[];
16
- };
17
- }
1
+ import { XmlIsrc } from './xml-isrc';
2
+ export declare class XmlIsrcList {
3
+ items: XmlIsrc[];
4
+ pushIsrc(isrc: string): void;
5
+ toXml(): {
6
+ name: string;
7
+ attrs: {
8
+ count: number;
9
+ };
10
+ children: {
11
+ name: string;
12
+ attrs: {
13
+ id: string;
14
+ };
15
+ }[];
16
+ };
17
+ }
@@ -1,22 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const xml_isrc_1 = require("./xml-isrc");
4
- class XmlIsrcList {
5
- constructor() {
6
- this.items = [];
7
- }
8
- pushIsrc(isrc) {
9
- this.items.push(new xml_isrc_1.XmlIsrc(isrc));
10
- }
11
- toXml() {
12
- return this.items.length === 0 ? null : {
13
- name: 'isrc-list',
14
- attrs: {
15
- count: this.items.length
16
- },
17
- children: this.items.map(isrc => isrc.toXml())
18
- };
19
- }
20
- }
21
- exports.XmlIsrcList = XmlIsrcList;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlIsrcList = void 0;
4
+ const xml_isrc_1 = require("./xml-isrc");
5
+ class XmlIsrcList {
6
+ constructor() {
7
+ this.items = [];
8
+ }
9
+ pushIsrc(isrc) {
10
+ this.items.push(new xml_isrc_1.XmlIsrc(isrc));
11
+ }
12
+ toXml() {
13
+ return this.items.length === 0 ? null : {
14
+ name: 'isrc-list',
15
+ attrs: {
16
+ count: this.items.length
17
+ },
18
+ children: this.items.map(isrc => isrc.toXml())
19
+ };
20
+ }
21
+ }
22
+ exports.XmlIsrcList = XmlIsrcList;
22
23
  //# sourceMappingURL=xml-isrc-list.js.map
@@ -1,10 +1,10 @@
1
- export declare class XmlIsrc {
2
- isrc: string;
3
- constructor(isrc: string);
4
- toXml(): {
5
- name: string;
6
- attrs: {
7
- id: string;
8
- };
9
- };
10
- }
1
+ export declare class XmlIsrc {
2
+ isrc: string;
3
+ constructor(isrc: string);
4
+ toXml(): {
5
+ name: string;
6
+ attrs: {
7
+ id: string;
8
+ };
9
+ };
10
+ }
@@ -1,17 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class XmlIsrc {
4
- constructor(isrc) {
5
- this.isrc = isrc;
6
- }
7
- toXml() {
8
- return {
9
- name: 'isrc',
10
- attrs: {
11
- id: this.isrc
12
- }
13
- };
14
- }
15
- }
16
- exports.XmlIsrc = XmlIsrc;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlIsrc = void 0;
4
+ class XmlIsrc {
5
+ constructor(isrc) {
6
+ this.isrc = isrc;
7
+ }
8
+ toXml() {
9
+ return {
10
+ name: 'isrc',
11
+ attrs: {
12
+ id: this.isrc
13
+ }
14
+ };
15
+ }
16
+ }
17
+ exports.XmlIsrc = XmlIsrc;
17
18
  //# sourceMappingURL=xml-isrc.js.map
@@ -1,6 +1,6 @@
1
- import { XmlRecording } from './xml-recording';
2
- export declare class XmlMetadata {
3
- recordings: XmlRecording[];
4
- pushRecording(id: string): XmlRecording;
5
- toXml(): string;
6
- }
1
+ import { XmlRecording } from './xml-recording';
2
+ export declare class XmlMetadata {
3
+ recordings: XmlRecording[];
4
+ pushRecording(id: string): XmlRecording;
5
+ toXml(): string;
6
+ }
@@ -1,29 +1,30 @@
1
- "use strict";
2
- // https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#ISRC_submission
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const jsontoxml = require("jsontoxml");
5
- const xml_recording_1 = require("./xml-recording");
6
- const ns_metadata = 'http://musicbrainz.org/ns/mmd-2.0#';
7
- class XmlMetadata {
8
- constructor() {
9
- this.recordings = [];
10
- }
11
- pushRecording(id) {
12
- const rec = new xml_recording_1.XmlRecording(id);
13
- this.recordings.push(rec);
14
- return rec;
15
- }
16
- toXml() {
17
- return jsontoxml([{
18
- name: 'metadata',
19
- attrs: {
20
- xmlns: ns_metadata
21
- },
22
- children: [{
23
- 'recording-list': this.recordings.map(rec => rec.toXml())
24
- }]
25
- }], { prettyPrint: false, escape: true, xmlHeader: true });
26
- }
27
- }
28
- exports.XmlMetadata = XmlMetadata;
1
+ "use strict";
2
+ // https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#ISRC_submission
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.XmlMetadata = void 0;
5
+ const jsontoxml = require("jsontoxml");
6
+ const xml_recording_1 = require("./xml-recording");
7
+ const ns_metadata = 'http://musicbrainz.org/ns/mmd-2.0#';
8
+ class XmlMetadata {
9
+ constructor() {
10
+ this.recordings = [];
11
+ }
12
+ pushRecording(id) {
13
+ const rec = new xml_recording_1.XmlRecording(id);
14
+ this.recordings.push(rec);
15
+ return rec;
16
+ }
17
+ toXml() {
18
+ return jsontoxml([{
19
+ name: 'metadata',
20
+ attrs: {
21
+ xmlns: ns_metadata
22
+ },
23
+ children: [{
24
+ 'recording-list': this.recordings.map(rec => rec.toXml())
25
+ }]
26
+ }], { prettyPrint: false, escape: true, xmlHeader: true });
27
+ }
28
+ }
29
+ exports.XmlMetadata = XmlMetadata;
29
30
  //# sourceMappingURL=xml-metadata.js.map
@@ -1,24 +1,24 @@
1
- import { XmlIsrcList } from './xml-isrc-list';
2
- export declare class XmlRecording {
3
- id: string;
4
- isrcList: XmlIsrcList;
5
- constructor(id: string);
6
- toXml(): {
7
- name: string;
8
- attrs: {
9
- id: string;
10
- };
11
- children: {
12
- name: string;
13
- attrs: {
14
- count: number;
15
- };
16
- children: {
17
- name: string;
18
- attrs: {
19
- id: string;
20
- };
21
- }[];
22
- }[];
23
- };
24
- }
1
+ import { XmlIsrcList } from './xml-isrc-list';
2
+ export declare class XmlRecording {
3
+ id: string;
4
+ isrcList: XmlIsrcList;
5
+ constructor(id: string);
6
+ toXml(): {
7
+ name: string;
8
+ attrs: {
9
+ id: string;
10
+ };
11
+ children: {
12
+ name: string;
13
+ attrs: {
14
+ count: number;
15
+ };
16
+ children: {
17
+ name: string;
18
+ attrs: {
19
+ id: string;
20
+ };
21
+ }[];
22
+ }[];
23
+ };
24
+ }
@@ -1,20 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const xml_isrc_list_1 = require("./xml-isrc-list");
4
- class XmlRecording {
5
- constructor(id) {
6
- this.id = id;
7
- this.isrcList = new xml_isrc_list_1.XmlIsrcList();
8
- }
9
- toXml() {
10
- return {
11
- name: 'recording',
12
- attrs: {
13
- id: this.id
14
- },
15
- children: [this.isrcList.toXml()]
16
- };
17
- }
18
- }
19
- exports.XmlRecording = XmlRecording;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlRecording = void 0;
4
+ const xml_isrc_list_1 = require("./xml-isrc-list");
5
+ class XmlRecording {
6
+ constructor(id) {
7
+ this.id = id;
8
+ this.isrcList = new xml_isrc_list_1.XmlIsrcList();
9
+ }
10
+ toXml() {
11
+ return {
12
+ name: 'recording',
13
+ attrs: {
14
+ id: this.id
15
+ },
16
+ children: [this.isrcList.toXml()]
17
+ };
18
+ }
19
+ }
20
+ exports.XmlRecording = XmlRecording;
20
21
  //# sourceMappingURL=xml-recording.js.map
package/package.json CHANGED
@@ -1,99 +1,98 @@
1
- {
2
- "name": "musicbrainz-api",
3
- "version": "0.5.2",
4
- "description": "MusicBrainz API client for reading and submitting metadata",
5
- "main": "lib/musicbrainz-api",
6
- "types": "lib/musicbrainz-api",
7
- "author": {
8
- "name": "Borewit",
9
- "url": "https://github.com/Borewit"
10
- },
11
- "keywords": [
12
- "MusicBrainz",
13
- "metadata",
14
- "meta",
15
- "tag",
16
- "tags",
17
- "Picard",
18
- "Discogs",
19
- "json",
20
- "xml",
21
- "web",
22
- "service",
23
- "submit",
24
- "metabrainz"
25
- ],
26
- "license": "MIT",
27
- "private": false,
28
- "devDependencies": {
29
- "@types/chai": "^4.2.0",
30
- "@types/mocha": "^5.2.7",
31
- "@types/node": "^12.7.2",
32
- "chai": "^4.2.0",
33
- "coveralls": "^3.0.6",
34
- "del-cli": "^2.0.0",
35
- "mocha": "^6.2.0",
36
- "nyc": "^14.1.1",
37
- "remark-cli": "^7.0.0",
38
- "remark-preset-lint-recommended": "^3.0.3",
39
- "ts-node": "^8.3.0",
40
- "tslint": "^5.19.0",
41
- "typescript": "^3.2.2"
42
- },
43
- "engines": {
44
- "node": "*"
45
- },
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/Borewit/musicbrainz-api.git"
49
- },
50
- "bugs": {
51
- "url": "https://github.com/Borewit/musicbrainz-api/issues"
52
- },
53
- "dependencies": {
54
- "@types/caseless": "^0.12.1",
55
- "@types/request-promise-native": "^1.0.15",
56
- "@types/uuid": "^3.4.4",
57
- "caseless": "^0.12.0",
58
- "debug": "^4.1.1",
59
- "http-status-codes": "^1.3.0",
60
- "json-stringify-safe": "^5.0.1",
61
- "jsontoxml": "^1.0.1",
62
- "request": "^2.88.0",
63
- "request-promise-native": "^1.0.5",
64
- "source-map-support": "^0.5.13",
65
- "uuid": "^3.3.2"
66
- },
67
- "scripts": {
68
- "clean": "del-cli lib/** src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map",
69
- "compile-src": "tsc -p src",
70
- "compile-test": "tsc -p test",
71
- "compile": "npm run compile-src && npm run compile-test",
72
- "lint-ts": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
73
- "lint-md": "remark -u preset-lint-recommended .",
74
- "lint": "npm run lint-md && npm run lint-ts",
75
- "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test-*.ts",
76
- "build": "npm run clean && npm run compile",
77
- "start": "npm-run-all compile lint cover-test",
78
- "test-coverage": "nyc npm run test",
79
- "send-coveralls": "nyc report --reporter=text-lcov | coveralls",
80
- "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage"
81
- },
82
- "nyc": {
83
- "exclude": [
84
- "lib/**",
85
- "test/**/*.ts",
86
- "src/**/*.js"
87
- ],
88
- "extension": [
89
- ".ts"
90
- ],
91
- "sourceMap": true,
92
- "instrument": true,
93
- "reporter": [
94
- "lcov",
95
- "text"
96
- ],
97
- "report-dir": "coverage"
98
- }
99
- }
1
+ {
2
+ "name": "musicbrainz-api",
3
+ "version": "0.7.2",
4
+ "description": "MusicBrainz API client for reading and submitting metadata",
5
+ "main": "lib/musicbrainz-api",
6
+ "types": "lib/musicbrainz-api",
7
+ "author": {
8
+ "name": "Borewit",
9
+ "url": "https://github.com/Borewit"
10
+ },
11
+ "keywords": [
12
+ "MusicBrainz",
13
+ "metadata",
14
+ "meta",
15
+ "tag",
16
+ "tags",
17
+ "Picard",
18
+ "json",
19
+ "xml",
20
+ "web",
21
+ "service",
22
+ "submit",
23
+ "metabrainz"
24
+ ],
25
+ "license": "MIT",
26
+ "private": false,
27
+ "devDependencies": {
28
+ "@types/chai": "^4.2.5",
29
+ "@types/mocha": "^9.0.0",
30
+ "@types/node": "^17.0.8",
31
+ "chai": "^4.2.0",
32
+ "coveralls": "^3.0.9",
33
+ "del-cli": "^4.0.1",
34
+ "mocha": "^9.0.1",
35
+ "nyc": "^15.0.0",
36
+ "remark-cli": "^10.0.1",
37
+ "remark-preset-lint-recommended": "^6.1.2",
38
+ "ts-node": "^10.0.0",
39
+ "tslint": "^6.1.1",
40
+ "typescript": "^4.0.2"
41
+ },
42
+ "engines": {
43
+ "node": "*"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/Borewit/musicbrainz-api.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/Borewit/musicbrainz-api/issues"
51
+ },
52
+ "dependencies": {
53
+ "@types/caseless": "^0.12.1",
54
+ "@types/request-promise-native": "^1.0.17",
55
+ "@types/uuid": "^8.3.0",
56
+ "caseless": "^0.12.0",
57
+ "debug": "^4.1.1",
58
+ "got": "^11.8.2",
59
+ "http-status-codes": "^2.1.4",
60
+ "json-stringify-safe": "^5.0.1",
61
+ "jsontoxml": "^1.0.1",
62
+ "source-map-support": "^0.5.16",
63
+ "tough-cookie": "^4.0.0",
64
+ "uuid": "^8.3.2"
65
+ },
66
+ "scripts": {
67
+ "clean": "del-cli lib/** src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map",
68
+ "compile-src": "tsc -p src",
69
+ "compile-test": "tsc -p test",
70
+ "compile": "npm run compile-src && npm run compile-test",
71
+ "lint-ts": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
72
+ "lint-md": "remark -u preset-lint-recommended .",
73
+ "lint": "npm run lint-md && npm run lint-ts",
74
+ "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test-*.ts",
75
+ "build": "npm run clean && npm run compile",
76
+ "start": "npm-run-all compile lint cover-test",
77
+ "test-coverage": "nyc npm run test",
78
+ "send-coveralls": "nyc report --reporter=text-lcov | coveralls",
79
+ "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage"
80
+ },
81
+ "nyc": {
82
+ "exclude": [
83
+ "lib/**",
84
+ "test/**/*.ts",
85
+ "src/**/*.js"
86
+ ],
87
+ "extension": [
88
+ ".ts"
89
+ ],
90
+ "sourceMap": true,
91
+ "instrument": true,
92
+ "reporter": [
93
+ "lcov",
94
+ "text"
95
+ ],
96
+ "report-dir": "coverage"
97
+ }
98
+ }