music-routes-data 3.4.0 → 5.0.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
@@ -6,19 +6,18 @@ Music Routes Data: What musicians played on which tracks?
6
6
  Schema
7
7
  ======
8
8
 
9
- Data is stored in eight JSON files in the `data` directory.
9
+ Data is stored in JSON files in the `data` directory.
10
10
 
11
- Four of the files contain basic data:
11
+ These files contain basic data:
12
12
 
13
13
  * `tracks.json` contains the `names` and unique `id` string for a track.
14
14
  * `releases.json` contains the `names` and unique `id` string for a release.
15
15
  * `artists.json` contains the `names` and unique `id` string for an artist.
16
16
  * `individuals.json` contains the `names` and unique `id` string for an individual.
17
17
 
18
- Four of the files describe relationships between the basic data and sometimes include extra data relevant to the relationship:
18
+ These files describe relationships between the basic data and sometimes include extra data relevant to the relationship:
19
19
 
20
20
  * `artist_track.json` contains `artistId` and `trackId` pairs where a track is attributed to an artist.
21
- * `individual_artist.json` contains `individualId` and `artistId` pairs where an individual is a member of an artist.
22
21
  * `individual_track.json` contains `individualId` and `trackId` pairs where the individual performed on the track. There is also an optional `credits` array that explains the person's role on the track (e.g., `["vocals","guitar"]`).
23
22
  * `track_release.json` contains `trackId` and `releaseId` pairs where a track appears on a release.
24
23
 
package/bin/mrd CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- var cli = require("../lib/cli");
4
- var argv = require('minimist')(process.argv.slice(2));
3
+ const cli = require('../lib/cli')
4
+ const argv = require('minimist')(process.argv.slice(2))
5
5
 
6
- cli.argv(argv);
6
+ cli.argv(argv)
package/bin/verify CHANGED
@@ -1,67 +1,103 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- var assert = require("assert");
4
- var Data = require("../lib/Data");
3
+ const assert = require('assert')
4
+ const path = require('path')
5
+ const Data = require('../lib/Data')
5
6
 
6
- var data = new Data();
7
+ const data = new Data()
7
8
 
8
- var rv;
9
-
10
- rv = data.read(__dirname + "/../data");
9
+ const rv = data.read(path.join(__dirname, '/../data'))
11
10
  if (rv.status === data.StatusEnum.ERROR) {
12
- console.error(rv.message || "Unknown error");
13
- process.exit(1);
11
+ console.error(rv.message || 'Unknown error')
12
+ process.exit(1)
14
13
  }
15
14
 
16
- var dump = {}; // local copy of all collections
15
+ const dump = {} // local copy of all collections
16
+
17
+ const collections = ['tracks', 'artists', 'releases', 'individuals', 'artist_track', 'individual_track', 'track_release']
18
+
19
+ collections.forEach(function (collection) {
20
+ const rv = data.search({ collection })
21
+ assert.ok(rv.status === data.StatusEnum.OK, 'Could not retrieve contents of collection ' + collection)
22
+ assert.ok(rv.results.length > 0, 'Collection ' + collection + ' has no entries')
23
+ dump[collection] = rv.results
24
+ })
25
+
26
+ const getSet = function (collectionName, options = {}) {
27
+ const idName = options.idName || '_id'
28
+ const ignoreDuplicates = options.ignoreDuplicates || false
29
+ const myArray = dump[collectionName].map((item) => item[idName])
30
+ const mySet = new Set(myArray)
31
+ if (!ignoreDuplicates) {
32
+ assert.strictEqual(mySet.size, myArray.length, `Duplicate IDs found in ${collectionName} collection`)
33
+ }
34
+ return mySet
35
+ }
17
36
 
18
- collections = ["tracks", "artists", "releases", "individuals", "artist_track", "individual_artist", "individual_track", "track_release"];
37
+ const compare = function (a, b, nameA, nameB) {
38
+ const diff = a.symmetricDifference(b)
39
+ assert.strictEqual(diff.size, 0, `The ${nameA} and ${nameB} collections have different IDs: ${Array.from(diff).join(', ')}`)
40
+ }
19
41
 
20
- collections.forEach(function(collection) {
21
- var rv = data.search({collection: collection});
22
- assert.ok(rv.status === data.StatusEnum.OK, "Could not retrieve contents of collection " + collection);
23
- assert.ok(rv.results.length > 0, "Collection " + collection + " has no entries");
24
- dump[collection] = rv.results;
25
- });
42
+ const trackIds = getSet('tracks')
43
+ const artistIds = getSet('artists')
44
+ const releaseIds = getSet('releases')
45
+ const individualIds = getSet('individuals')
26
46
 
27
- // Check that all instances of basic are included in relation as propName.
28
- // For example, all instances of 'artists' included in 'at' as 'artistId'
29
- dump.included = function (basic, relation, propName) {
47
+ const artistTrackIds = {
48
+ artist: getSet('artist_track', { idName: 'artist_id', ignoreDuplicates: true }),
49
+ track: getSet('artist_track', { idName: 'track_id', ignoreDuplicates: true })
50
+ }
51
+ compare(artistTrackIds.artist, artistIds, 'artist_track', 'artist_id')
52
+ compare(artistTrackIds.track, trackIds, 'artist_track', 'track_id')
30
53
 
31
- var related = function (basicValue) {
54
+ const individualTrackIds = {
55
+ individual: getSet('individual_track', { idName: 'individual_id', ignoreDuplicates: true }),
56
+ track: getSet('individual_track', { idName: 'track_id', ignoreDuplicates: true })
57
+ }
58
+ compare(individualTrackIds.individual, individualIds, 'individual_track', 'individual_id')
59
+ compare(individualTrackIds.track, trackIds, 'individual_track', 'track_id')
32
60
 
33
- var _idInRelatedTable = function (relationValue) {
34
- return relationValue[propName] === basicValue._id;
35
- };
61
+ const trackReleaseIds = {
62
+ release: getSet('track_release', { idName: 'release_id', ignoreDuplicates: true }),
63
+ track: getSet('track_release', { idName: 'track_id', ignoreDuplicates: true })
64
+ }
65
+ compare(trackReleaseIds.release, releaseIds, 'track_release', 'release_id')
66
+ compare(trackReleaseIds.track, trackIds, 'track_release', 'track_id')
67
+
68
+ // Check that all instances of basic are included in relation as propName.
69
+ // For example, check that all instances of 'artists' are included in 'at' as 'artistId'.
70
+ dump.included = function (basic, relation, propName) {
71
+ const related = function (basicValue) {
72
+ const _idInRelatedTable = function (relationValue) {
73
+ return relationValue[propName] === basicValue._id
74
+ }
36
75
 
37
- var rv = dump[relation].some(_idInRelatedTable);
76
+ const rv = dump[relation].some(_idInRelatedTable)
38
77
 
39
- if (! rv) {
40
- console.log("`" + basic + "` contains _id " + basicValue._id + " but it is not found in `" + relation + "` as `" + propName + "`");
78
+ if (!rv) {
79
+ console.log('`' + basic + '` contains _id ' + basicValue._id + ' but it is not found in `' + relation + '` as `' + propName + '`')
41
80
  }
42
81
 
43
- return rv;
44
- };
82
+ return rv
83
+ }
45
84
 
46
- return dump[basic].every(related);
47
- };
85
+ return dump[basic].every(related)
86
+ }
48
87
 
49
- //TODO: Correct/expand data so that all of these are true.
50
88
  // All artists should have tracks.
51
- assert.ok(dump.included("artists", "artist_track", "artist_id"));
89
+ assert.ok(dump.included('artists', 'artist_track', 'artist_id'))
52
90
  // All tracks should have artists.
53
- assert.ok(dump.included("tracks", "artist_track", "track_id"));
54
- // All artists have individuals. (Not all individuals are members of artists, though.)
55
- // assert.ok(dump.included("artists", "individual_artist", "artist_id"));
91
+ assert.ok(dump.included('tracks', 'artist_track', 'track_id'))
56
92
  // All individuals are associated with at least one track.
57
- // assert.ok(dump.included("individuals", "individual_track", "individual_id"));
93
+ assert.ok(dump.included('individuals', 'individual_track', 'individual_id'))
94
+ // All tracks are associated with at least one individual.
95
+ assert.ok(dump.included('tracks', 'individual_track', 'track_id'))
58
96
  // All tracks are on at least one release.
59
- assert.ok(dump.included("tracks", "track_release", "track_id"));
97
+ assert.ok(dump.included('tracks', 'track_release', 'track_id'))
60
98
  // All releases have at least one track.
61
- assert.ok(dump.included("releases", "track_release", "release_id"));
99
+ assert.ok(dump.included('releases', 'track_release', 'release_id'))
62
100
 
63
- // TODO: Make sure that all artist IDs that appear in artist_track actually exist in artists, etc.
64
- // TODO: Make sure that all _ids are unique
65
101
  // TODO: Make sure that all required fields are present in every entry (including "credits", yeah? even if empty)
66
102
  // TODO: Make sure that there are no duplicate link entries (Elvis on "Love Me Tender" exists twice should be an error)
67
103
  // TODO: Check that all fields that should be strings are strings and all fields that should be arrays of strings are arrays of strings
@@ -41523,10 +41523,6 @@
41523
41523
  "artist_id": "1517",
41524
41524
  "track_id": "10255"
41525
41525
  },
41526
- {
41527
- "artist_id": "591",
41528
- "track_id": "10256"
41529
- },
41530
41526
  {
41531
41527
  "artist_id": "483",
41532
41528
  "track_id": "10257"
@@ -41607,10 +41603,6 @@
41607
41603
  "artist_id": "1520",
41608
41604
  "track_id": "10276"
41609
41605
  },
41610
- {
41611
- "artist_id": "1521",
41612
- "track_id": "10277"
41613
- },
41614
41606
  {
41615
41607
  "artist_id": "1522",
41616
41608
  "track_id": "10278"
@@ -41687,26 +41679,6 @@
41687
41679
  "artist_id": "1531",
41688
41680
  "track_id": "10297"
41689
41681
  },
41690
- {
41691
- "artist_id": "1531",
41692
- "track_id": "10298"
41693
- },
41694
- {
41695
- "artist_id": "1531",
41696
- "track_id": "10299"
41697
- },
41698
- {
41699
- "artist_id": "1531",
41700
- "track_id": "10300"
41701
- },
41702
- {
41703
- "artist_id": "1531",
41704
- "track_id": "10301"
41705
- },
41706
- {
41707
- "artist_id": "1532",
41708
- "track_id": "10302"
41709
- },
41710
41682
  {
41711
41683
  "artist_id": "1533",
41712
41684
  "track_id": "10303"
@@ -41771,14 +41743,6 @@
41771
41743
  "artist_id": "1537",
41772
41744
  "track_id": "10318"
41773
41745
  },
41774
- {
41775
- "artist_id": "1538",
41776
- "track_id": "10319"
41777
- },
41778
- {
41779
- "artist_id": "1538",
41780
- "track_id": "10320"
41781
- },
41782
41746
  {
41783
41747
  "artist_id": "1539",
41784
41748
  "track_id": "10321"
@@ -41959,10 +41923,6 @@
41959
41923
  "artist_id": "1547",
41960
41924
  "track_id": "10365"
41961
41925
  },
41962
- {
41963
- "artist_id": "1422",
41964
- "track_id": "10366"
41965
- },
41966
41926
  {
41967
41927
  "artist_id": "1548",
41968
41928
  "track_id": "10367"
@@ -42571,10 +42531,6 @@
42571
42531
  "artist_id": "1234",
42572
42532
  "track_id": "10517"
42573
42533
  },
42574
- {
42575
- "artist_id": "1234",
42576
- "track_id": "10518"
42577
- },
42578
42534
  {
42579
42535
  "artist_id": "1234",
42580
42536
  "track_id": "10519"
@@ -43271,10 +43227,6 @@
43271
43227
  "artist_id": "479",
43272
43228
  "track_id": "10692"
43273
43229
  },
43274
- {
43275
- "artist_id": "479",
43276
- "track_id": "10693"
43277
- },
43278
43230
  {
43279
43231
  "artist_id": "479",
43280
43232
  "track_id": "10694"
@@ -45047,34 +44999,6 @@
45047
44999
  "artist_id": "2",
45048
45000
  "track_id": "11135"
45049
45001
  },
45050
- {
45051
- "artist_id": "2",
45052
- "track_id": "11136"
45053
- },
45054
- {
45055
- "artist_id": "2",
45056
- "track_id": "11137"
45057
- },
45058
- {
45059
- "artist_id": "2",
45060
- "track_id": "11138"
45061
- },
45062
- {
45063
- "artist_id": "2",
45064
- "track_id": "11139"
45065
- },
45066
- {
45067
- "artist_id": "2",
45068
- "track_id": "11140"
45069
- },
45070
- {
45071
- "artist_id": "2",
45072
- "track_id": "11141"
45073
- },
45074
- {
45075
- "artist_id": "2",
45076
- "track_id": "11142"
45077
- },
45078
45002
  {
45079
45003
  "artist_id": "2",
45080
45004
  "track_id": "11143"
@@ -45363,10 +45287,6 @@
45363
45287
  "artist_id": "2",
45364
45288
  "track_id": "11215"
45365
45289
  },
45366
- {
45367
- "artist_id": "2",
45368
- "track_id": "11216"
45369
- },
45370
45290
  {
45371
45291
  "artist_id": "2",
45372
45292
  "track_id": "11217"
@@ -47975,14 +47895,6 @@
47975
47895
  "artist_id": "97",
47976
47896
  "track_id": "11837"
47977
47897
  },
47978
- {
47979
- "artist_id": "97",
47980
- "track_id": "11838"
47981
- },
47982
- {
47983
- "artist_id": "97",
47984
- "track_id": "11839"
47985
- },
47986
47898
  {
47987
47899
  "artist_id": "97",
47988
47900
  "track_id": "11840"
@@ -48727,18 +48639,10 @@
48727
48639
  "artist_id": "212",
48728
48640
  "track_id": "12025"
48729
48641
  },
48730
- {
48731
- "artist_id": "212",
48732
- "track_id": "12026"
48733
- },
48734
48642
  {
48735
48643
  "artist_id": "212",
48736
48644
  "track_id": "12027"
48737
48645
  },
48738
- {
48739
- "artist_id": "212",
48740
- "track_id": "12028"
48741
- },
48742
48646
  {
48743
48647
  "artist_id": "212",
48744
48648
  "track_id": "12029"
@@ -48975,10 +48879,6 @@
48975
48879
  "artist_id": "212",
48976
48880
  "track_id": "12087"
48977
48881
  },
48978
- {
48979
- "artist_id": "212",
48980
- "track_id": "12088"
48981
- },
48982
48882
  {
48983
48883
  "artist_id": "212",
48984
48884
  "track_id": "12089"
@@ -49267,10 +49167,6 @@
49267
49167
  "artist_id": "212",
49268
49168
  "track_id": "12160"
49269
49169
  },
49270
- {
49271
- "artist_id": "212",
49272
- "track_id": "12161"
49273
- },
49274
49170
  {
49275
49171
  "artist_id": "212",
49276
49172
  "track_id": "12162"
@@ -49287,18 +49183,6 @@
49287
49183
  "artist_id": "212",
49288
49184
  "track_id": "12165"
49289
49185
  },
49290
- {
49291
- "artist_id": "212",
49292
- "track_id": "12166"
49293
- },
49294
- {
49295
- "artist_id": "212",
49296
- "track_id": "12167"
49297
- },
49298
- {
49299
- "artist_id": "212",
49300
- "track_id": "12168"
49301
- },
49302
49186
  {
49303
49187
  "artist_id": "212",
49304
49188
  "track_id": "12169"
@@ -50247,10 +50131,6 @@
50247
50131
  "artist_id": "2",
50248
50132
  "track_id": "12403"
50249
50133
  },
50250
- {
50251
- "artist_id": "2",
50252
- "track_id": "12404"
50253
- },
50254
50134
  {
50255
50135
  "artist_id": "2",
50256
50136
  "track_id": "12405"
package/data/artists.json CHANGED
@@ -8955,12 +8955,6 @@
8955
8955
  "Actionslacks"
8956
8956
  ]
8957
8957
  },
8958
- {
8959
- "_id": "1521",
8960
- "names": [
8961
- "The Admirals"
8962
- ]
8963
- },
8964
8958
  {
8965
8959
  "_id": "1522",
8966
8960
  "names": [
@@ -9021,12 +9015,6 @@
9021
9015
  "Robert Craft"
9022
9016
  ]
9023
9017
  },
9024
- {
9025
- "_id": "1532",
9026
- "names": [
9027
- "Edgar Varèse"
9028
- ]
9029
- },
9030
9018
  {
9031
9019
  "_id": "1533",
9032
9020
  "names": [
@@ -9057,12 +9045,6 @@
9057
9045
  "Common"
9058
9046
  ]
9059
9047
  },
9060
- {
9061
- "_id": "1538",
9062
- "names": [
9063
- "David Fanshawe"
9064
- ]
9065
- },
9066
9048
  {
9067
9049
  "_id": "1539",
9068
9050
  "names": [