music-routes-data 5.1.5 → 6.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 +50 -9
- package/bin/verify +1 -53
- package/data/tracks.json +189602 -0
- package/doc/cli/help.txt +9 -3
- package/lib/Data/index.js +16 -7
- package/lib/Data/validate-track.js +14 -0
- package/lib/cli/add.js +10 -2
- package/lib/cli/link.js +1 -1
- package/package.json +1 -1
- package/data/artist_track.json +0 -54742
- package/data/artists.json +0 -10470
- package/data/releases.json +0 -14823
- package/data/track_release.json +0 -54246
package/README.md
CHANGED
|
@@ -8,18 +8,59 @@ Schema
|
|
|
8
8
|
|
|
9
9
|
Data is stored in JSON files in the `data` directory.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The graph has three collections:
|
|
12
12
|
|
|
13
|
-
* `tracks.json
|
|
14
|
-
* `
|
|
15
|
-
* `
|
|
16
|
-
|
|
13
|
+
* `tracks.json`: recordings, identified by a unique `_id` string.
|
|
14
|
+
* `individuals.json`: people, each with a unique `_id` string and a `names` array.
|
|
15
|
+
* `individual_track.json`: performance relationships with `individual_id` and
|
|
16
|
+
`track_id` strings, plus an optional `credits` array (for example,
|
|
17
|
+
`["vocals", "guitar"]`).
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Every track has this structure:
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"_id": "36",
|
|
24
|
+
"names": ["Under Pressure"],
|
|
25
|
+
"artists": [
|
|
26
|
+
{ "names": ["Queen"] },
|
|
27
|
+
{ "names": ["David Bowie"] }
|
|
28
|
+
],
|
|
29
|
+
"releases": [
|
|
30
|
+
{ "names": ["The Best Of 1980/1987"] },
|
|
31
|
+
{ "names": ["80s Hits"] }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`artists` and `releases` are required arrays with at least one entry. Each entry
|
|
37
|
+
has a required, non-empty `names` array containing non-empty strings. Additional
|
|
38
|
+
names are aliases for that same artist or release; separate entries represent
|
|
39
|
+
separate artists or releases. These metadata objects have no IDs.
|
|
40
|
+
|
|
41
|
+
`bin/verify` validates this requirement when loading the data, in addition to
|
|
42
|
+
checking IDs and performance relationships. The data library also rejects invalid
|
|
43
|
+
track metadata on creation, reading, and writing. `npm test` runs the tests and
|
|
44
|
+
validates the full dataset.
|
|
45
|
+
|
|
46
|
+
Migration from version 5
|
|
47
|
+
========================
|
|
48
|
+
|
|
49
|
+
This is a breaking schema change. The `artists`, `releases`, `artist_track`, and
|
|
50
|
+
`track_release` collections have been removed, including their JSON files and
|
|
51
|
+
support in the data library and CLI. Artist and release names (including aliases)
|
|
52
|
+
are embedded directly in each associated track. Track IDs, individual IDs, and
|
|
53
|
+
performance relationships are unchanged.
|
|
54
|
+
|
|
55
|
+
Consumers should read `track.artists` and `track.releases` instead of joining the
|
|
56
|
+
removed collections. Artist and release metadata is now local to a track;
|
|
57
|
+
corrections affecting multiple tracks must update each occurrence. Recordings
|
|
58
|
+
with the same title still have distinct track IDs when they are different
|
|
59
|
+
performances, such as studio, demo, and live versions.
|
|
60
|
+
|
|
61
|
+
For CLI usage, see [the command help](doc/cli/help.txt). Adding a track now requires
|
|
62
|
+
JSON metadata containing both arrays. Adding individuals and linking people to
|
|
63
|
+
tracks continue to work as before.
|
|
23
64
|
|
|
24
65
|
License
|
|
25
66
|
=======
|
package/bin/verify
CHANGED
|
@@ -14,7 +14,7 @@ if (rv.status === data.StatusEnum.ERROR) {
|
|
|
14
14
|
|
|
15
15
|
const dump = {} // local copy of all collections
|
|
16
16
|
|
|
17
|
-
const collections = ['tracks', '
|
|
17
|
+
const collections = ['tracks', 'individuals', 'individual_track']
|
|
18
18
|
|
|
19
19
|
collections.forEach(function (collection) {
|
|
20
20
|
const rv = data.search({ collection })
|
|
@@ -40,8 +40,6 @@ const compare = function (a, b, nameA, nameB) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const trackIds = getSet('tracks')
|
|
43
|
-
const artistIds = getSet('artists')
|
|
44
|
-
const releaseIds = getSet('releases')
|
|
45
43
|
const individualIds = getSet('individuals')
|
|
46
44
|
|
|
47
45
|
// All IDs are strings but must not contain colons or slashes because the visualizer
|
|
@@ -50,16 +48,7 @@ const validateIds = (idsSet) => {
|
|
|
50
48
|
assert.ok(idsSet.values().every((id) => typeof id === 'string' && !id.includes(':') && !id.includes('/')), 'Invalid ID found')
|
|
51
49
|
}
|
|
52
50
|
validateIds(trackIds)
|
|
53
|
-
validateIds(artistIds)
|
|
54
51
|
validateIds(individualIds)
|
|
55
|
-
validateIds(releaseIds)
|
|
56
|
-
|
|
57
|
-
const artistTrackIds = {
|
|
58
|
-
artist: getSet('artist_track', { idName: 'artist_id', ignoreDuplicates: true }),
|
|
59
|
-
track: getSet('artist_track', { idName: 'track_id', ignoreDuplicates: true })
|
|
60
|
-
}
|
|
61
|
-
compare(artistTrackIds.artist, artistIds, 'artist_track', 'artist_id')
|
|
62
|
-
compare(artistTrackIds.track, trackIds, 'artist_track', 'track_id')
|
|
63
52
|
|
|
64
53
|
const individualTrackIds = {
|
|
65
54
|
individual: getSet('individual_track', { idName: 'individual_id', ignoreDuplicates: true }),
|
|
@@ -68,47 +57,6 @@ const individualTrackIds = {
|
|
|
68
57
|
compare(individualTrackIds.individual, individualIds, 'individual_track', 'individual_id')
|
|
69
58
|
compare(individualTrackIds.track, trackIds, 'individual_track', 'track_id')
|
|
70
59
|
|
|
71
|
-
const trackReleaseIds = {
|
|
72
|
-
release: getSet('track_release', { idName: 'release_id', ignoreDuplicates: true }),
|
|
73
|
-
track: getSet('track_release', { idName: 'track_id', ignoreDuplicates: true })
|
|
74
|
-
}
|
|
75
|
-
compare(trackReleaseIds.release, releaseIds, 'track_release', 'release_id')
|
|
76
|
-
compare(trackReleaseIds.track, trackIds, 'track_release', 'track_id')
|
|
77
|
-
|
|
78
|
-
// Check that all instances of basic are included in relation as propName.
|
|
79
|
-
// For example, check that all instances of 'artists' are included in 'at' as 'artistId'.
|
|
80
|
-
dump.included = function (basic, relation, propName) {
|
|
81
|
-
const related = function (basicValue) {
|
|
82
|
-
const _idInRelatedTable = function (relationValue) {
|
|
83
|
-
return relationValue[propName] === basicValue._id
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const rv = dump[relation].some(_idInRelatedTable)
|
|
87
|
-
|
|
88
|
-
if (!rv) {
|
|
89
|
-
console.log('`' + basic + '` contains _id ' + basicValue._id + ' but it is not found in `' + relation + '` as `' + propName + '`')
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return rv
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return dump[basic].every(related)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// All artists should have tracks.
|
|
99
|
-
assert.ok(dump.included('artists', 'artist_track', 'artist_id'))
|
|
100
|
-
// All tracks should have artists.
|
|
101
|
-
assert.ok(dump.included('tracks', 'artist_track', 'track_id'))
|
|
102
|
-
// All individuals are associated with at least one track.
|
|
103
|
-
assert.ok(dump.included('individuals', 'individual_track', 'individual_id'))
|
|
104
|
-
// All tracks are associated with at least one individual.
|
|
105
|
-
assert.ok(dump.included('tracks', 'individual_track', 'track_id'))
|
|
106
|
-
// All tracks are on at least one release.
|
|
107
|
-
assert.ok(dump.included('tracks', 'track_release', 'track_id'))
|
|
108
|
-
// All releases have at least one track.
|
|
109
|
-
assert.ok(dump.included('releases', 'track_release', 'release_id'))
|
|
110
|
-
|
|
111
|
-
// TODO: Make sure that all required fields are present in every entry (including "credits", yeah? even if empty)
|
|
112
60
|
// TODO: Make sure that there are no duplicate link entries (Elvis on "Love Me Tender" exists twice should be an error)
|
|
113
61
|
// TODO: Check that all fields that should be strings are strings and all fields that should be arrays of strings are arrays of strings
|
|
114
62
|
// TODO: Check for extra fields that we don't know about. Only _id, names, credits, etc. should be in there. No weird things.
|