onelibrary-connect 1.1.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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/adapter.d.ts +111 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +537 -0
- package/dist/adapter.js.map +1 -0
- package/dist/connection.d.ts +9 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +17 -0
- package/dist/connection.js.map +1 -0
- package/dist/database-adapter.d.ts +50 -0
- package/dist/database-adapter.d.ts.map +1 -0
- package/dist/database-adapter.js +8 -0
- package/dist/database-adapter.js.map +1 -0
- package/dist/encryption.d.ts +11 -0
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +70 -0
- package/dist/encryption.js.map +1 -0
- package/dist/entities.d.ts +116 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +10 -0
- package/dist/entities.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +251 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +72 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +150 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +40 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chris Le
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# onelibrary-connect
|
|
2
|
+
|
|
3
|
+
Read and query rekordbox **OneLibrary** (`exportLibrary.db`) SQLCipher databases
|
|
4
|
+
from Pioneer DJ / AlphaTheta devices. Useful for inspecting USB exports, CDJ
|
|
5
|
+
SD cards, and the OneLibrary databases used by modern rekordbox versions.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install onelibrary-connect
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This package depends on `better-sqlite3-multiple-ciphers` for SQLCipher
|
|
14
|
+
decryption. It will be built as a native module on install.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { OneLibraryAdapter } from 'onelibrary-connect';
|
|
20
|
+
|
|
21
|
+
const db = new OneLibraryAdapter('/path/to/exportLibrary.db');
|
|
22
|
+
|
|
23
|
+
// Look up a single track
|
|
24
|
+
const track = db.findTrack(1);
|
|
25
|
+
console.log(`${track.artist?.name} - ${track.title}`);
|
|
26
|
+
|
|
27
|
+
// Iterate every track
|
|
28
|
+
for (const t of db.findAllTracks()) {
|
|
29
|
+
console.log(t.id, t.title, t.tempo, t.key?.name);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Walk the playlist tree
|
|
33
|
+
const { folders, playlists, trackEntries } = db.findPlaylist();
|
|
34
|
+
for (const playlist of playlists) {
|
|
35
|
+
const trackIds = db.findPlaylistContents(playlist.id);
|
|
36
|
+
console.log(`${playlist.name}: ${trackIds.length} tracks`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// History sessions (one per DJ set recorded on the device)
|
|
40
|
+
for (const session of db.findHistorySessions()) {
|
|
41
|
+
const trackIds = db.findHistoryContents(session.id);
|
|
42
|
+
console.log(`${session.name}: ${trackIds.length} tracks`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
db.close();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### `new OneLibraryAdapter(dbPath: string)`
|
|
51
|
+
|
|
52
|
+
Open a OneLibrary database. The file is opened read-only and decrypted with the
|
|
53
|
+
built-in SQLCipher key used by Pioneer DJ devices.
|
|
54
|
+
|
|
55
|
+
### Track queries
|
|
56
|
+
|
|
57
|
+
- `findTrack(id)` — Find a track by `content_id`, with joined artist, album,
|
|
58
|
+
genre, key, color, label, artwork, remixer, original artist, and composer
|
|
59
|
+
- `findAllTracks()` — Return every track in the library
|
|
60
|
+
|
|
61
|
+
### Cue queries
|
|
62
|
+
|
|
63
|
+
- `findCues(trackId)` — Return all cue points, loops, hot cues, and hot loops
|
|
64
|
+
for a track as a unified `CueAndLoop[]`
|
|
65
|
+
|
|
66
|
+
### Playlist queries
|
|
67
|
+
|
|
68
|
+
- `findPlaylist(playlistId?)` — Return `{ folders, playlists, trackEntries }`
|
|
69
|
+
for a given playlist ID, or the root if omitted
|
|
70
|
+
- `findPlaylistById(id)` — Fetch a single playlist row
|
|
71
|
+
- `findPlaylistContents(id)` — Track IDs in order for a playlist
|
|
72
|
+
|
|
73
|
+
### MyTag queries
|
|
74
|
+
|
|
75
|
+
- `findMyTags(parentId?)` — Return `{ folders, tags }` for MyTags
|
|
76
|
+
- `findMyTagById(id)` / `findMyTagContents(id)` / `findMyTagsForTrack(trackId)`
|
|
77
|
+
|
|
78
|
+
### History queries
|
|
79
|
+
|
|
80
|
+
- `findHistorySessions()` — All history sessions on the device
|
|
81
|
+
- `findHistoryContents(historyId)` — Track IDs in a session
|
|
82
|
+
|
|
83
|
+
### Hot cue bank lists
|
|
84
|
+
|
|
85
|
+
- `findHotCueBankLists()` — All hot cue bank lists
|
|
86
|
+
- `findHotCueBankListCues(bankListId)` — Cue IDs in a bank list
|
|
87
|
+
|
|
88
|
+
### Menu / sort configuration
|
|
89
|
+
|
|
90
|
+
- `findMenuItems()` — All browse menu items
|
|
91
|
+
- `findVisibleCategories()` — Categories the user has enabled
|
|
92
|
+
- `findVisibleSortOptions()` — Sort options the user has enabled
|
|
93
|
+
|
|
94
|
+
### Reference tables
|
|
95
|
+
|
|
96
|
+
- `findArtist(id)`, `findAlbum(id)`, `findGenre(id)`, `findKey(id)`,
|
|
97
|
+
`findColor(id)`, `findLabel(id)`, `findArtwork(id)`
|
|
98
|
+
|
|
99
|
+
### Device properties
|
|
100
|
+
|
|
101
|
+
- `getProperty()` — Returns `{ deviceName, dbVersion, numberOfContents,
|
|
102
|
+
createdDate, backgroundColorType }`
|
|
103
|
+
|
|
104
|
+
### Low-level
|
|
105
|
+
|
|
106
|
+
- `openOneLibraryDb(path)` — Open the SQLCipher database directly without the
|
|
107
|
+
adapter wrapper
|
|
108
|
+
- `getEncryptionKey()` — Returns the SQLCipher key
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneLibrary Database Adapter
|
|
3
|
+
*
|
|
4
|
+
* Provides an interface for reading the OneLibrary (exportLibrary.db) SQLite database
|
|
5
|
+
* used by modern rekordbox versions and Pioneer DJ devices.
|
|
6
|
+
*/
|
|
7
|
+
import type { Album, Artist, Artwork, Color, EntityFK, Genre, Key, Label, Playlist, PlaylistEntry, Track } from './entities.js';
|
|
8
|
+
import type { CueAndLoop } from './types.js';
|
|
9
|
+
import type { Category, DeviceProperty, HistorySession, HotCueBankList, MenuItem, MyTag, SortOption } from './types.js';
|
|
10
|
+
import type { DatabaseAdapter, DatabaseType } from './database-adapter.js';
|
|
11
|
+
/**
|
|
12
|
+
* Adapter for OneLibrary database that matches the ORM interface.
|
|
13
|
+
* Queries the SQLite file directly instead of hydrating into memory.
|
|
14
|
+
*/
|
|
15
|
+
export declare class OneLibraryAdapter implements DatabaseAdapter {
|
|
16
|
+
#private;
|
|
17
|
+
readonly type: DatabaseType;
|
|
18
|
+
constructor(dbPath: string);
|
|
19
|
+
/**
|
|
20
|
+
* Close the database connection
|
|
21
|
+
*/
|
|
22
|
+
close(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Find a track by ID
|
|
25
|
+
*/
|
|
26
|
+
findTrack(id: number): Track | null;
|
|
27
|
+
/**
|
|
28
|
+
* Find all tracks in the database
|
|
29
|
+
*/
|
|
30
|
+
findAllTracks(): Track[];
|
|
31
|
+
/**
|
|
32
|
+
* Find cue points for a track
|
|
33
|
+
*/
|
|
34
|
+
findCues(trackId: number): CueAndLoop[];
|
|
35
|
+
/**
|
|
36
|
+
* Find a playlist by ID
|
|
37
|
+
*/
|
|
38
|
+
findPlaylistById(playlistId: number): Playlist | null;
|
|
39
|
+
/**
|
|
40
|
+
* Query for a list of {folders, playlists, tracks} given a playlist ID.
|
|
41
|
+
* If no ID is provided the root list is queried.
|
|
42
|
+
*/
|
|
43
|
+
findPlaylist(playlistId?: number): {
|
|
44
|
+
folders: Playlist[];
|
|
45
|
+
playlists: Playlist[];
|
|
46
|
+
trackEntries: PlaylistEntry<EntityFK.WithFKs>[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Get track IDs for a playlist in order
|
|
50
|
+
*/
|
|
51
|
+
findPlaylistContents(playlistId: number): number[];
|
|
52
|
+
findArtist(artistId: number): Artist | null;
|
|
53
|
+
findAlbum(albumId: number): Album | null;
|
|
54
|
+
findGenre(genreId: number): Genre | null;
|
|
55
|
+
findKey(keyId: number): Key | null;
|
|
56
|
+
findColor(colorId: number): Color | null;
|
|
57
|
+
findLabel(labelId: number): Label | null;
|
|
58
|
+
findArtwork(imageId: number): Artwork | null;
|
|
59
|
+
/**
|
|
60
|
+
* Find all root-level MyTags (folders and tags with no parent)
|
|
61
|
+
*/
|
|
62
|
+
findMyTags(parentId?: number): {
|
|
63
|
+
folders: MyTag[];
|
|
64
|
+
tags: MyTag[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Find a MyTag by ID
|
|
68
|
+
*/
|
|
69
|
+
findMyTagById(myTagId: number): MyTag | null;
|
|
70
|
+
/**
|
|
71
|
+
* Get track IDs for a MyTag
|
|
72
|
+
*/
|
|
73
|
+
findMyTagContents(myTagId: number): number[];
|
|
74
|
+
/**
|
|
75
|
+
* Get all MyTags assigned to a track
|
|
76
|
+
*/
|
|
77
|
+
findMyTagsForTrack(trackId: number): MyTag[];
|
|
78
|
+
/**
|
|
79
|
+
* Find all history sessions
|
|
80
|
+
*/
|
|
81
|
+
findHistorySessions(): HistorySession[];
|
|
82
|
+
/**
|
|
83
|
+
* Get track IDs for a history session in order
|
|
84
|
+
*/
|
|
85
|
+
findHistoryContents(historyId: number): number[];
|
|
86
|
+
/**
|
|
87
|
+
* Find all hot cue bank lists
|
|
88
|
+
*/
|
|
89
|
+
findHotCueBankLists(): HotCueBankList[];
|
|
90
|
+
/**
|
|
91
|
+
* Get cue IDs for a hot cue bank list
|
|
92
|
+
*/
|
|
93
|
+
findHotCueBankListCues(bankListId: number): number[];
|
|
94
|
+
/**
|
|
95
|
+
* Get all menu items (browse categories)
|
|
96
|
+
*/
|
|
97
|
+
findMenuItems(): MenuItem[];
|
|
98
|
+
/**
|
|
99
|
+
* Get visible categories with their menu item info
|
|
100
|
+
*/
|
|
101
|
+
findVisibleCategories(): Category[];
|
|
102
|
+
/**
|
|
103
|
+
* Get visible sort options
|
|
104
|
+
*/
|
|
105
|
+
findVisibleSortOptions(): SortOption[];
|
|
106
|
+
/**
|
|
107
|
+
* Get device properties
|
|
108
|
+
*/
|
|
109
|
+
getProperty(): DeviceProperty | null;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,EACH,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EACN,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,UAAU,EAAyB,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAoBzE;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,eAAe;;IACvD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAgB;gBAK/B,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,KAAK,IAAI,IAAI;IAqBb;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAoCnC;;OAEG;IACH,aAAa,IAAI,KAAK,EAAE;IAyGxB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE;IAmEvC;;OAEG;IACH,gBA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