@rocksky/sdk 0.14.0 → 0.14.1
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/dist/client.d.ts +30 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/generated/types.d.ts +83 -27
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/library.d.ts +101 -11
- package/dist/library.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.test.ts +83 -0
- package/src/client.ts +61 -5
- package/src/generated/types.ts +92 -31
- package/src/index.ts +8 -1
- package/src/library.ts +115 -19
package/src/library.ts
CHANGED
|
@@ -2,6 +2,88 @@ import type { Client } from "@atcute/client";
|
|
|
2
2
|
|
|
3
3
|
import { RockskyError } from "./errors.js";
|
|
4
4
|
|
|
5
|
+
/** A song in the library, in the Subsonic `Child` shape. */
|
|
6
|
+
export interface LibrarySong {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
artist: string;
|
|
10
|
+
album: string;
|
|
11
|
+
albumArtist?: string;
|
|
12
|
+
/** Seconds, not milliseconds — Subsonic's unit. */
|
|
13
|
+
duration: number;
|
|
14
|
+
coverArt?: string;
|
|
15
|
+
albumId?: string;
|
|
16
|
+
artistId?: string;
|
|
17
|
+
track?: number;
|
|
18
|
+
discNumber?: number;
|
|
19
|
+
genre?: string;
|
|
20
|
+
suffix?: string;
|
|
21
|
+
contentType?: string;
|
|
22
|
+
size?: number;
|
|
23
|
+
musicBrainzId?: string;
|
|
24
|
+
samplingRate?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A library playlist. Subsonic's `Playlist` shape plus two Rocksky extensions:
|
|
29
|
+
* `uri` and `trackArts`.
|
|
30
|
+
*/
|
|
31
|
+
export interface LibraryPlaylist {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
songCount: number;
|
|
35
|
+
/** Seconds. */
|
|
36
|
+
duration: number;
|
|
37
|
+
created: string;
|
|
38
|
+
changed: string;
|
|
39
|
+
public: boolean;
|
|
40
|
+
comment?: string;
|
|
41
|
+
coverArt?: string;
|
|
42
|
+
/**
|
|
43
|
+
* AT-URI of the `app.rocksky.playlist` record this playlist is mirrored to.
|
|
44
|
+
* Absent while the record has yet to be published.
|
|
45
|
+
*/
|
|
46
|
+
uri?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Album art of up to four of the playlist's tracks, oldest first — enough
|
|
49
|
+
* for a cover mosaic. Absent when none of them have art.
|
|
50
|
+
*/
|
|
51
|
+
trackArts?: string[];
|
|
52
|
+
/** Only present on `getPlaylist`. */
|
|
53
|
+
entry?: LibrarySong[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Envelope every navidrome method replies with. */
|
|
57
|
+
interface SubsonicResponse {
|
|
58
|
+
status: string;
|
|
59
|
+
version?: string;
|
|
60
|
+
type?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Reply to a playlist mutation.
|
|
65
|
+
*
|
|
66
|
+
* The playlist is mirrored to the caller's PDS as an `app.rocksky.playlist`
|
|
67
|
+
* record. That mirror runs after the library has already been updated, so it
|
|
68
|
+
* can't fail the call: when it does fail, the library change still stands and
|
|
69
|
+
* the reason lands in `atprotoError` for the caller to surface.
|
|
70
|
+
*/
|
|
71
|
+
export interface LibraryPlaylistMutation extends SubsonicResponse {
|
|
72
|
+
/** The resulting playlist — `createPlaylist` only. */
|
|
73
|
+
playlist?: LibraryPlaylist;
|
|
74
|
+
/** AT-URI of the mirrored record, when one was published or already existed. */
|
|
75
|
+
uri?: string;
|
|
76
|
+
atprotoError?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface LibraryPlaylistsResponse extends SubsonicResponse {
|
|
80
|
+
playlists: { playlist: LibraryPlaylist[] };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface LibraryPlaylistResponse extends SubsonicResponse {
|
|
84
|
+
playlist: LibraryPlaylist;
|
|
85
|
+
}
|
|
86
|
+
|
|
5
87
|
/**
|
|
6
88
|
* Authenticated client for the `app.rocksky.library.*` API — the Subsonic /
|
|
7
89
|
* navidrome-compatible surface over a user's uploaded music.
|
|
@@ -160,28 +242,42 @@ export class RockskyLibrary {
|
|
|
160
242
|
}
|
|
161
243
|
|
|
162
244
|
/** `app.rocksky.library.getPlaylists` — requires auth. */
|
|
163
|
-
getPlaylists(): Promise<
|
|
164
|
-
return this.query<
|
|
245
|
+
getPlaylists(): Promise<LibraryPlaylistsResponse> {
|
|
246
|
+
return this.query<LibraryPlaylistsResponse>("app.rocksky.library.getPlaylists", {});
|
|
165
247
|
}
|
|
166
248
|
|
|
167
249
|
/** `app.rocksky.library.getPlaylist` — requires auth. */
|
|
168
|
-
getPlaylist(id: string): Promise<
|
|
169
|
-
return this.query<
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return this.procedure<
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
|
|
184
|
-
|
|
250
|
+
getPlaylist(id: string): Promise<LibraryPlaylistResponse> {
|
|
251
|
+
return this.query<LibraryPlaylistResponse>("app.rocksky.library.getPlaylist", { id });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* `app.rocksky.library.createPlaylist` — requires auth.
|
|
256
|
+
*
|
|
257
|
+
* Also publishes an `app.rocksky.playlist` record to the caller's PDS; see
|
|
258
|
+
* {@link LibraryPlaylistMutation} for how a failure there is reported.
|
|
259
|
+
*/
|
|
260
|
+
createPlaylist(name: string): Promise<LibraryPlaylistMutation> {
|
|
261
|
+
return this.procedure<LibraryPlaylistMutation>("app.rocksky.library.createPlaylist", { name });
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* `app.rocksky.library.updatePlaylist` — requires auth.
|
|
266
|
+
*
|
|
267
|
+
* Renames, adds a song or removes the song at a position, and replays the
|
|
268
|
+
* same change onto the mirrored record.
|
|
269
|
+
*/
|
|
270
|
+
updatePlaylist(playlistId: string, opts: { name?: string; comment?: string; songIdToAdd?: string; songIndexToRemove?: number } = {}): Promise<LibraryPlaylistMutation> {
|
|
271
|
+
return this.procedure<LibraryPlaylistMutation>("app.rocksky.library.updatePlaylist", { playlistId, ...opts });
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* `app.rocksky.library.deletePlaylist` — requires auth.
|
|
276
|
+
*
|
|
277
|
+
* Retracts the mirrored record and the caller's entries in it too.
|
|
278
|
+
*/
|
|
279
|
+
deletePlaylist(id: string): Promise<LibraryPlaylistMutation> {
|
|
280
|
+
return this.procedure<LibraryPlaylistMutation>("app.rocksky.library.deletePlaylist", { id });
|
|
185
281
|
}
|
|
186
282
|
|
|
187
283
|
/** `app.rocksky.library.deleteSong` — requires auth. */
|