@rocksky/sdk 0.13.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/README.md +4 -2
- package/dist/client.d.ts +49 -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/dedup.js +215 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/generated/types.d.ts +83 -27
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/hash.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -209
- package/dist/library.d.ts +101 -11
- package/dist/library.d.ts.map +1 -1
- package/dist/remote.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/agent.ts +3 -3
- package/src/client.test.ts +83 -0
- package/src/client.ts +114 -7
- package/src/errors.ts +7 -2
- package/src/generated/types.ts +92 -31
- package/src/hash.ts +4 -2
- package/src/index.ts +11 -2
- package/src/library.ts +117 -21
- package/src/remote.ts +4 -5
package/dist/index.js
CHANGED
|
@@ -19,11 +19,13 @@ var RockskyError;
|
|
|
19
19
|
var init_errors = __esm(() => {
|
|
20
20
|
RockskyError = class RockskyError extends Error {
|
|
21
21
|
kind;
|
|
22
|
-
|
|
22
|
+
status;
|
|
23
|
+
constructor(payload, status) {
|
|
23
24
|
const p = payload;
|
|
24
25
|
super(p?.message || p?.error || "rocksky request failed");
|
|
25
26
|
this.name = "RockskyError";
|
|
26
27
|
this.kind = p?.error;
|
|
28
|
+
this.status = status;
|
|
27
29
|
}
|
|
28
30
|
};
|
|
29
31
|
});
|
|
@@ -42,7 +44,7 @@ class RockskyLibrary {
|
|
|
42
44
|
}
|
|
43
45
|
const res = await this.rpc.get(nsid, { params: clean });
|
|
44
46
|
if (!res.ok)
|
|
45
|
-
throw new RockskyError(res.data);
|
|
47
|
+
throw new RockskyError(res.data, res.status);
|
|
46
48
|
return res.data;
|
|
47
49
|
}
|
|
48
50
|
async procedure(nsid, input) {
|
|
@@ -53,7 +55,7 @@ class RockskyLibrary {
|
|
|
53
55
|
}
|
|
54
56
|
const res = await this.rpc.post(nsid, { input: clean });
|
|
55
57
|
if (!res.ok)
|
|
56
|
-
throw new RockskyError(res.data);
|
|
58
|
+
throw new RockskyError(res.data, res.status);
|
|
57
59
|
return res.data;
|
|
58
60
|
}
|
|
59
61
|
ping() {
|
|
@@ -209,10 +211,11 @@ class RockskyClient {
|
|
|
209
211
|
let handler = simpleFetchHandler({ service: appview });
|
|
210
212
|
if (token) {
|
|
211
213
|
const inner = handler;
|
|
212
|
-
handler = (pathname, init) =>
|
|
213
|
-
|
|
214
|
-
headers
|
|
215
|
-
|
|
214
|
+
handler = (pathname, init) => {
|
|
215
|
+
const headers = new Headers(init?.headers);
|
|
216
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
217
|
+
return inner(pathname, { ...init, headers });
|
|
218
|
+
};
|
|
216
219
|
}
|
|
217
220
|
this.rpc = new Client({ handler });
|
|
218
221
|
}
|
|
@@ -230,7 +233,7 @@ class RockskyClient {
|
|
|
230
233
|
}
|
|
231
234
|
const res = await this.rpc.get(nsid, { params: clean });
|
|
232
235
|
if (!res.ok)
|
|
233
|
-
throw new RockskyError(res.data);
|
|
236
|
+
throw new RockskyError(res.data, res.status);
|
|
234
237
|
return res.data;
|
|
235
238
|
}
|
|
236
239
|
profile(actor) {
|
|
@@ -247,6 +250,20 @@ class RockskyClient {
|
|
|
247
250
|
get(nsid, params = {}) {
|
|
248
251
|
return this.query(nsid, params);
|
|
249
252
|
}
|
|
253
|
+
async post(nsid, opts = {}) {
|
|
254
|
+
const clean = {};
|
|
255
|
+
for (const [k, v] of Object.entries(opts.params ?? {})) {
|
|
256
|
+
if (v !== undefined && v !== "")
|
|
257
|
+
clean[k] = v;
|
|
258
|
+
}
|
|
259
|
+
const call = { params: clean };
|
|
260
|
+
if (opts.body !== undefined)
|
|
261
|
+
call.input = opts.body;
|
|
262
|
+
const res = await this.rpc.post(nsid, call);
|
|
263
|
+
if (!res.ok)
|
|
264
|
+
throw new RockskyError(res.data, res.status);
|
|
265
|
+
return res.data;
|
|
266
|
+
}
|
|
250
267
|
async songs(actor, limit = 50, offset = 0) {
|
|
251
268
|
const out = await this.query("app.rocksky.actor.getActorSongs", {
|
|
252
269
|
did: actor,
|
|
@@ -457,6 +474,25 @@ class RockskyClient {
|
|
|
457
474
|
playlist(uri) {
|
|
458
475
|
return this.query("app.rocksky.playlist.getPlaylist", { uri });
|
|
459
476
|
}
|
|
477
|
+
createPlaylist(input) {
|
|
478
|
+
return this.post("app.rocksky.playlist.createPlaylist", { params: input });
|
|
479
|
+
}
|
|
480
|
+
updatePlaylist(input) {
|
|
481
|
+
return this.post("app.rocksky.playlist.updatePlaylist", { params: input });
|
|
482
|
+
}
|
|
483
|
+
addSongs(uri, songs) {
|
|
484
|
+
return this.post("app.rocksky.playlist.addSongs", {
|
|
485
|
+
params: { uri, songs }
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
removePlaylist(uri) {
|
|
489
|
+
return this.post("app.rocksky.playlist.removePlaylist", { params: { uri } });
|
|
490
|
+
}
|
|
491
|
+
removeTrack(uri, songUri) {
|
|
492
|
+
return this.post("app.rocksky.playlist.removeTrack", {
|
|
493
|
+
params: { uri, songUri }
|
|
494
|
+
});
|
|
495
|
+
}
|
|
460
496
|
albumShouts(uri, limit = 50, offset = 0) {
|
|
461
497
|
return this.query("app.rocksky.shout.getAlbumShouts", { uri, limit, offset });
|
|
462
498
|
}
|
|
@@ -489,9 +525,24 @@ class RockskyClient {
|
|
|
489
525
|
input: ids && ids.length ? { ids } : {}
|
|
490
526
|
});
|
|
491
527
|
if (!res.ok)
|
|
492
|
-
throw new RockskyError(res.data);
|
|
528
|
+
throw new RockskyError(res.data, res.status);
|
|
493
529
|
return res.data;
|
|
494
530
|
}
|
|
531
|
+
followAccount(account) {
|
|
532
|
+
return this.post("app.rocksky.graph.followAccount", { params: { account } });
|
|
533
|
+
}
|
|
534
|
+
unfollowAccount(account) {
|
|
535
|
+
return this.post("app.rocksky.graph.unfollowAccount", { params: { account } });
|
|
536
|
+
}
|
|
537
|
+
createScrobble(input) {
|
|
538
|
+
return this.post("app.rocksky.scrobble.createScrobble", { body: input });
|
|
539
|
+
}
|
|
540
|
+
putMirrorSource(input) {
|
|
541
|
+
return this.post("app.rocksky.mirror.putMirrorSource", { body: input });
|
|
542
|
+
}
|
|
543
|
+
putAudioSettings(input) {
|
|
544
|
+
return this.post("app.rocksky.rockbox.putAudioSettings", { body: input });
|
|
545
|
+
}
|
|
495
546
|
}
|
|
496
547
|
var Interval, DEFAULT_APPVIEW = "https://api.rocksky.app";
|
|
497
548
|
var init_client = __esm(() => {
|
|
@@ -745,7 +796,7 @@ class Agent {
|
|
|
745
796
|
input: { repo: this.did, collection, record: { ...record, $type: collection } }
|
|
746
797
|
});
|
|
747
798
|
if (!res.ok)
|
|
748
|
-
throw new RockskyError(res.data);
|
|
799
|
+
throw new RockskyError(res.data, res.status);
|
|
749
800
|
return res.data.uri;
|
|
750
801
|
}
|
|
751
802
|
async putRecord(collection, rkey, record) {
|
|
@@ -754,7 +805,7 @@ class Agent {
|
|
|
754
805
|
input: { repo: this.did, collection, rkey, record: { ...record, $type: collection } }
|
|
755
806
|
});
|
|
756
807
|
if (!res.ok)
|
|
757
|
-
throw new RockskyError(res.data);
|
|
808
|
+
throw new RockskyError(res.data, res.status);
|
|
758
809
|
return res.data.uri;
|
|
759
810
|
}
|
|
760
811
|
async delete(collection, rkey) {
|
|
@@ -763,7 +814,7 @@ class Agent {
|
|
|
763
814
|
input: { repo: this.did, collection, rkey }
|
|
764
815
|
});
|
|
765
816
|
if (!res.ok)
|
|
766
|
-
throw new RockskyError(res.data);
|
|
817
|
+
throw new RockskyError(res.data, res.status);
|
|
767
818
|
}
|
|
768
819
|
async scrobble(rec) {
|
|
769
820
|
const record = { ...rec, createdAt: rec.createdAt || nowISO() };
|
|
@@ -904,200 +955,6 @@ class Agent {
|
|
|
904
955
|
return this.delete(C_STATUS, "self");
|
|
905
956
|
}
|
|
906
957
|
}
|
|
907
|
-
// src/dedup.ts
|
|
908
|
-
import { fromUint8Array } from "@atcute/car";
|
|
909
|
-
import { decode as cborDecode, fromBytes, isBytes, isCidLink } from "@atcute/cbor";
|
|
910
|
-
import { toString as cidToString } from "@atcute/cid";
|
|
911
|
-
import { ClassicLevel } from "classic-level";
|
|
912
|
-
|
|
913
|
-
// src/hash.ts
|
|
914
|
-
import { createHash } from "node:crypto";
|
|
915
|
-
function sha256Lower(s) {
|
|
916
|
-
return createHash("sha256").update(s.toLowerCase()).digest("hex");
|
|
917
|
-
}
|
|
918
|
-
function songHash(title, artist, album) {
|
|
919
|
-
return sha256Lower(`${title} - ${artist} - ${album}`);
|
|
920
|
-
}
|
|
921
|
-
function albumHash(album, albumArtist) {
|
|
922
|
-
return sha256Lower(`${album} - ${albumArtist}`);
|
|
923
|
-
}
|
|
924
|
-
function artistHash(albumArtist) {
|
|
925
|
-
return sha256Lower(albumArtist);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// src/dedup.ts
|
|
929
|
-
var C_ARTIST2 = "app.rocksky.artist";
|
|
930
|
-
var C_ALBUM2 = "app.rocksky.album";
|
|
931
|
-
var C_SONG2 = "app.rocksky.song";
|
|
932
|
-
var C_SCROBBLE2 = "app.rocksky.scrobble";
|
|
933
|
-
var SEP = "\x00";
|
|
934
|
-
function totalIndexed(s) {
|
|
935
|
-
return s.artists + s.albums + s.songs + s.scrobbles;
|
|
936
|
-
}
|
|
937
|
-
function identKey(did, col, hash) {
|
|
938
|
-
return `${did}${SEP}${col}${SEP}${hash}`;
|
|
939
|
-
}
|
|
940
|
-
function scrobbleKey(did, songH, secs) {
|
|
941
|
-
return `${did}${SEP}${C_SCROBBLE2}${SEP}${songH}${SEP}${secs}`;
|
|
942
|
-
}
|
|
943
|
-
function primaryFor(did, col, rec) {
|
|
944
|
-
const s = (k) => typeof rec[k] === "string" ? rec[k] : "";
|
|
945
|
-
switch (col) {
|
|
946
|
-
case C_ARTIST2:
|
|
947
|
-
return s("name") ? identKey(did, C_ARTIST2, artistHash(s("name"))) : undefined;
|
|
948
|
-
case C_ALBUM2:
|
|
949
|
-
return s("title") && s("artist") ? identKey(did, C_ALBUM2, albumHash(s("title"), s("artist"))) : undefined;
|
|
950
|
-
case C_SONG2:
|
|
951
|
-
return s("title") && s("artist") && s("album") ? identKey(did, C_SONG2, songHash(s("title"), s("artist"), s("album"))) : undefined;
|
|
952
|
-
case C_SCROBBLE2: {
|
|
953
|
-
if (s("title") && s("artist") && s("album") && s("createdAt")) {
|
|
954
|
-
const secs = Math.floor(Date.parse(s("createdAt")) / 1000);
|
|
955
|
-
if (!Number.isNaN(secs))
|
|
956
|
-
return scrobbleKey(did, songHash(s("title"), s("artist"), s("album")), secs);
|
|
957
|
-
}
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
class RockskyIndex {
|
|
965
|
-
db;
|
|
966
|
-
constructor(path) {
|
|
967
|
-
this.db = new ClassicLevel(path, { keyEncoding: "utf8", valueEncoding: "utf8" });
|
|
968
|
-
}
|
|
969
|
-
open() {
|
|
970
|
-
return this.db.open();
|
|
971
|
-
}
|
|
972
|
-
close() {
|
|
973
|
-
return this.db.close();
|
|
974
|
-
}
|
|
975
|
-
async get(key) {
|
|
976
|
-
try {
|
|
977
|
-
return await this.db.get(key);
|
|
978
|
-
} catch {
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
songUri(did, title, artist, album) {
|
|
983
|
-
return this.get(identKey(did, C_SONG2, songHash(title, artist, album)));
|
|
984
|
-
}
|
|
985
|
-
albumUri(did, album, albumArtist) {
|
|
986
|
-
return this.get(identKey(did, C_ALBUM2, albumHash(album, albumArtist)));
|
|
987
|
-
}
|
|
988
|
-
artistUri(did, albumArtist) {
|
|
989
|
-
return this.get(identKey(did, C_ARTIST2, artistHash(albumArtist)));
|
|
990
|
-
}
|
|
991
|
-
scrobbleUri(did, title, artist, album, secs) {
|
|
992
|
-
return this.get(scrobbleKey(did, songHash(title, artist, album), secs));
|
|
993
|
-
}
|
|
994
|
-
async putPrimary(did, col, primary, uri) {
|
|
995
|
-
const rkey = uri.slice(uri.lastIndexOf("/") + 1);
|
|
996
|
-
await this.db.batch([
|
|
997
|
-
{ type: "put", key: primary, value: uri },
|
|
998
|
-
{ type: "put", key: `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`, value: primary }
|
|
999
|
-
]);
|
|
1000
|
-
}
|
|
1001
|
-
recordSong(did, title, artist, album, uri) {
|
|
1002
|
-
return this.putPrimary(did, C_SONG2, identKey(did, C_SONG2, songHash(title, artist, album)), uri);
|
|
1003
|
-
}
|
|
1004
|
-
recordAlbum(did, album, albumArtist, uri) {
|
|
1005
|
-
return this.putPrimary(did, C_ALBUM2, identKey(did, C_ALBUM2, albumHash(album, albumArtist)), uri);
|
|
1006
|
-
}
|
|
1007
|
-
recordArtist(did, albumArtist, uri) {
|
|
1008
|
-
return this.putPrimary(did, C_ARTIST2, identKey(did, C_ARTIST2, artistHash(albumArtist)), uri);
|
|
1009
|
-
}
|
|
1010
|
-
recordScrobble(did, title, artist, album, secs, uri) {
|
|
1011
|
-
return this.putPrimary(did, C_SCROBBLE2, scrobbleKey(did, songHash(title, artist, album), secs), uri);
|
|
1012
|
-
}
|
|
1013
|
-
cursor(did) {
|
|
1014
|
-
return this.get(`${SEP}meta${SEP}cursor${SEP}${did}`).then((v) => v ? Number(v) : 0);
|
|
1015
|
-
}
|
|
1016
|
-
async setCursor(did, timeUS) {
|
|
1017
|
-
await this.db.put(`${SEP}meta${SEP}cursor${SEP}${did}`, String(timeUS));
|
|
1018
|
-
}
|
|
1019
|
-
async indexCar(did, car) {
|
|
1020
|
-
const reader = fromUint8Array(car);
|
|
1021
|
-
const blocks = new Map;
|
|
1022
|
-
for (const entry of reader)
|
|
1023
|
-
blocks.set(cidToString(entry.cid), entry.bytes);
|
|
1024
|
-
const root = reader.roots[0];
|
|
1025
|
-
if (!root)
|
|
1026
|
-
throw new Error("CAR has no root");
|
|
1027
|
-
const commit = cborDecode(blocks.get(root.$link));
|
|
1028
|
-
const stats = { artists: 0, albums: 0, songs: 0, scrobbles: 0 };
|
|
1029
|
-
const ops = [];
|
|
1030
|
-
for (const [path, valueLink] of walkMst(blocks, commit.data.$link)) {
|
|
1031
|
-
const slash = path.indexOf("/");
|
|
1032
|
-
if (slash < 0)
|
|
1033
|
-
continue;
|
|
1034
|
-
const col = path.slice(0, slash);
|
|
1035
|
-
const rkey = path.slice(slash + 1);
|
|
1036
|
-
if (col !== C_ARTIST2 && col !== C_ALBUM2 && col !== C_SONG2 && col !== C_SCROBBLE2)
|
|
1037
|
-
continue;
|
|
1038
|
-
const recBytes = blocks.get(valueLink);
|
|
1039
|
-
if (!recBytes)
|
|
1040
|
-
continue;
|
|
1041
|
-
const rec = cborDecode(recBytes);
|
|
1042
|
-
const primary = primaryFor(did, col, rec);
|
|
1043
|
-
if (!primary)
|
|
1044
|
-
continue;
|
|
1045
|
-
const uri = `at://${did}/${col}/${rkey}`;
|
|
1046
|
-
ops.push({ type: "put", key: primary, value: uri });
|
|
1047
|
-
ops.push({ type: "put", key: `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`, value: primary });
|
|
1048
|
-
if (col === C_ARTIST2)
|
|
1049
|
-
stats.artists++;
|
|
1050
|
-
else if (col === C_ALBUM2)
|
|
1051
|
-
stats.albums++;
|
|
1052
|
-
else if (col === C_SONG2)
|
|
1053
|
-
stats.songs++;
|
|
1054
|
-
else
|
|
1055
|
-
stats.scrobbles++;
|
|
1056
|
-
}
|
|
1057
|
-
if (commit.rev)
|
|
1058
|
-
ops.push({ type: "put", key: `${SEP}meta${SEP}rev${SEP}${did}`, value: commit.rev });
|
|
1059
|
-
await this.db.batch(ops);
|
|
1060
|
-
return stats;
|
|
1061
|
-
}
|
|
1062
|
-
async applyCommit(did, col, operation, rkey, record) {
|
|
1063
|
-
if (operation === "create" || operation === "update") {
|
|
1064
|
-
if (!record)
|
|
1065
|
-
return;
|
|
1066
|
-
const primary = primaryFor(did, col, record);
|
|
1067
|
-
if (!primary)
|
|
1068
|
-
return;
|
|
1069
|
-
await this.putPrimary(did, col, primary, `at://${did}/${col}/${rkey}`);
|
|
1070
|
-
} else if (operation === "delete") {
|
|
1071
|
-
const rk = `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`;
|
|
1072
|
-
const primary = await this.get(rk);
|
|
1073
|
-
if (primary) {
|
|
1074
|
-
await this.db.batch([
|
|
1075
|
-
{ type: "del", key: primary },
|
|
1076
|
-
{ type: "del", key: rk }
|
|
1077
|
-
]);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
function* walkMst(blocks, cid) {
|
|
1083
|
-
const raw = blocks.get(cid);
|
|
1084
|
-
if (!raw)
|
|
1085
|
-
return;
|
|
1086
|
-
const node = cborDecode(raw);
|
|
1087
|
-
if (node.l && isCidLink(node.l))
|
|
1088
|
-
yield* walkMst(blocks, node.l.$link);
|
|
1089
|
-
let last = new Uint8Array(0);
|
|
1090
|
-
for (const e of node.e) {
|
|
1091
|
-
const suffix = isBytes(e.k) ? fromBytes(e.k) : e.k;
|
|
1092
|
-
const key = new Uint8Array(e.p + suffix.length);
|
|
1093
|
-
key.set(last.subarray(0, e.p), 0);
|
|
1094
|
-
key.set(suffix, e.p);
|
|
1095
|
-
yield [new TextDecoder().decode(key), e.v.$link];
|
|
1096
|
-
last = key;
|
|
1097
|
-
if (e.t && isCidLink(e.t))
|
|
1098
|
-
yield* walkMst(blocks, e.t.$link);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
958
|
// src/remote-player.ts
|
|
1102
959
|
var DEFAULT_REMOTE_WS = "wss://api.rocksky.app/ws";
|
|
1103
960
|
|
|
@@ -1742,6 +1599,21 @@ var ScrobbleFields = {
|
|
|
1742
1599
|
artistName: "artist.name",
|
|
1743
1600
|
artistGenres: "artist.genres"
|
|
1744
1601
|
};
|
|
1602
|
+
// src/hash.ts
|
|
1603
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
1604
|
+
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
1605
|
+
function sha256Lower(s) {
|
|
1606
|
+
return bytesToHex(sha256(new TextEncoder().encode(s.toLowerCase())));
|
|
1607
|
+
}
|
|
1608
|
+
function songHash(title, artist, album) {
|
|
1609
|
+
return sha256Lower(`${title} - ${artist} - ${album}`);
|
|
1610
|
+
}
|
|
1611
|
+
function albumHash(album, albumArtist) {
|
|
1612
|
+
return sha256Lower(`${album} - ${albumArtist}`);
|
|
1613
|
+
}
|
|
1614
|
+
function artistHash(albumArtist) {
|
|
1615
|
+
return sha256Lower(albumArtist);
|
|
1616
|
+
}
|
|
1745
1617
|
|
|
1746
1618
|
// src/index.ts
|
|
1747
1619
|
init_errors();
|
|
@@ -1760,13 +1632,11 @@ export {
|
|
|
1760
1632
|
RemotePlayer,
|
|
1761
1633
|
RockskyClient,
|
|
1762
1634
|
RockskyError,
|
|
1763
|
-
RockskyIndex,
|
|
1764
1635
|
RockskyLibrary,
|
|
1765
1636
|
ScrobbleFields,
|
|
1766
1637
|
SongFields,
|
|
1767
1638
|
albumHash,
|
|
1768
1639
|
artistHash,
|
|
1769
1640
|
runJetstream,
|
|
1770
|
-
songHash
|
|
1771
|
-
totalIndexed
|
|
1641
|
+
songHash
|
|
1772
1642
|
};
|
package/dist/library.d.ts
CHANGED
|
@@ -1,4 +1,82 @@
|
|
|
1
1
|
import type { Client } from "@atcute/client";
|
|
2
|
+
/** A song in the library, in the Subsonic `Child` shape. */
|
|
3
|
+
export interface LibrarySong {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
artist: string;
|
|
7
|
+
album: string;
|
|
8
|
+
albumArtist?: string;
|
|
9
|
+
/** Seconds, not milliseconds — Subsonic's unit. */
|
|
10
|
+
duration: number;
|
|
11
|
+
coverArt?: string;
|
|
12
|
+
albumId?: string;
|
|
13
|
+
artistId?: string;
|
|
14
|
+
track?: number;
|
|
15
|
+
discNumber?: number;
|
|
16
|
+
genre?: string;
|
|
17
|
+
suffix?: string;
|
|
18
|
+
contentType?: string;
|
|
19
|
+
size?: number;
|
|
20
|
+
musicBrainzId?: string;
|
|
21
|
+
samplingRate?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A library playlist. Subsonic's `Playlist` shape plus two Rocksky extensions:
|
|
25
|
+
* `uri` and `trackArts`.
|
|
26
|
+
*/
|
|
27
|
+
export interface LibraryPlaylist {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
songCount: number;
|
|
31
|
+
/** Seconds. */
|
|
32
|
+
duration: number;
|
|
33
|
+
created: string;
|
|
34
|
+
changed: string;
|
|
35
|
+
public: boolean;
|
|
36
|
+
comment?: string;
|
|
37
|
+
coverArt?: string;
|
|
38
|
+
/**
|
|
39
|
+
* AT-URI of the `app.rocksky.playlist` record this playlist is mirrored to.
|
|
40
|
+
* Absent while the record has yet to be published.
|
|
41
|
+
*/
|
|
42
|
+
uri?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Album art of up to four of the playlist's tracks, oldest first — enough
|
|
45
|
+
* for a cover mosaic. Absent when none of them have art.
|
|
46
|
+
*/
|
|
47
|
+
trackArts?: string[];
|
|
48
|
+
/** Only present on `getPlaylist`. */
|
|
49
|
+
entry?: LibrarySong[];
|
|
50
|
+
}
|
|
51
|
+
/** Envelope every navidrome method replies with. */
|
|
52
|
+
interface SubsonicResponse {
|
|
53
|
+
status: string;
|
|
54
|
+
version?: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reply to a playlist mutation.
|
|
59
|
+
*
|
|
60
|
+
* The playlist is mirrored to the caller's PDS as an `app.rocksky.playlist`
|
|
61
|
+
* record. That mirror runs after the library has already been updated, so it
|
|
62
|
+
* can't fail the call: when it does fail, the library change still stands and
|
|
63
|
+
* the reason lands in `atprotoError` for the caller to surface.
|
|
64
|
+
*/
|
|
65
|
+
export interface LibraryPlaylistMutation extends SubsonicResponse {
|
|
66
|
+
/** The resulting playlist — `createPlaylist` only. */
|
|
67
|
+
playlist?: LibraryPlaylist;
|
|
68
|
+
/** AT-URI of the mirrored record, when one was published or already existed. */
|
|
69
|
+
uri?: string;
|
|
70
|
+
atprotoError?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface LibraryPlaylistsResponse extends SubsonicResponse {
|
|
73
|
+
playlists: {
|
|
74
|
+
playlist: LibraryPlaylist[];
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export interface LibraryPlaylistResponse extends SubsonicResponse {
|
|
78
|
+
playlist: LibraryPlaylist;
|
|
79
|
+
}
|
|
2
80
|
/**
|
|
3
81
|
* Authenticated client for the `app.rocksky.library.*` API — the Subsonic /
|
|
4
82
|
* navidrome-compatible surface over a user's uploaded music.
|
|
@@ -98,23 +176,34 @@ export declare class RockskyLibrary {
|
|
|
98
176
|
artistId?: string;
|
|
99
177
|
}): Promise<unknown>;
|
|
100
178
|
/** `app.rocksky.library.getPlaylists` — requires auth. */
|
|
101
|
-
getPlaylists(): Promise<
|
|
179
|
+
getPlaylists(): Promise<LibraryPlaylistsResponse>;
|
|
102
180
|
/** `app.rocksky.library.getPlaylist` — requires auth. */
|
|
103
|
-
getPlaylist(id: string): Promise<
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
181
|
+
getPlaylist(id: string): Promise<LibraryPlaylistResponse>;
|
|
182
|
+
/**
|
|
183
|
+
* `app.rocksky.library.createPlaylist` — requires auth.
|
|
184
|
+
*
|
|
185
|
+
* Also publishes an `app.rocksky.playlist` record to the caller's PDS; see
|
|
186
|
+
* {@link LibraryPlaylistMutation} for how a failure there is reported.
|
|
187
|
+
*/
|
|
188
|
+
createPlaylist(name: string): Promise<LibraryPlaylistMutation>;
|
|
189
|
+
/**
|
|
190
|
+
* `app.rocksky.library.updatePlaylist` — requires auth.
|
|
191
|
+
*
|
|
192
|
+
* Renames, adds a song or removes the song at a position, and replays the
|
|
193
|
+
* same change onto the mirrored record.
|
|
194
|
+
*/
|
|
107
195
|
updatePlaylist(playlistId: string, opts?: {
|
|
108
196
|
name?: string;
|
|
109
197
|
comment?: string;
|
|
110
198
|
songIdToAdd?: string;
|
|
111
199
|
songIndexToRemove?: number;
|
|
112
|
-
}): Promise<
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
200
|
+
}): Promise<LibraryPlaylistMutation>;
|
|
201
|
+
/**
|
|
202
|
+
* `app.rocksky.library.deletePlaylist` — requires auth.
|
|
203
|
+
*
|
|
204
|
+
* Retracts the mirrored record and the caller's entries in it too.
|
|
205
|
+
*/
|
|
206
|
+
deletePlaylist(id: string): Promise<LibraryPlaylistMutation>;
|
|
118
207
|
/** `app.rocksky.library.deleteSong` — requires auth. */
|
|
119
208
|
deleteSong(id: string): Promise<{
|
|
120
209
|
status: string;
|
|
@@ -162,4 +251,5 @@ export declare class RockskyLibrary {
|
|
|
162
251
|
/** `app.rocksky.library.getInternetRadioStations` — requires auth. */
|
|
163
252
|
getInternetRadioStations(): Promise<unknown>;
|
|
164
253
|
}
|
|
254
|
+
export {};
|
|
165
255
|
//# sourceMappingURL=library.d.ts.map
|
package/dist/library.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,MAAM;YA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ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocksky/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "TypeScript SDK for Rocksky — built on atcute: AppView reads, AT Protocol PDS writes (scrobble, like, follow, shout), a local dedup index, and Jetstream real-time sync.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"types": "./dist/remote.d.ts",
|
|
27
27
|
"import": "./dist/remote.js",
|
|
28
28
|
"default": "./dist/remote.js"
|
|
29
|
+
},
|
|
30
|
+
"./dedup": {
|
|
31
|
+
"types": "./dist/dedup.d.ts",
|
|
32
|
+
"import": "./dist/dedup.js",
|
|
33
|
+
"default": "./dist/dedup.js"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"files": [
|
|
@@ -34,7 +39,7 @@
|
|
|
34
39
|
"README.md"
|
|
35
40
|
],
|
|
36
41
|
"scripts": {
|
|
37
|
-
"build": "bun build ./src/index.ts ./src/remote.ts --outdir ./dist --target node --format esm --packages external && bun run build:types",
|
|
42
|
+
"build": "bun build ./src/index.ts ./src/remote.ts ./src/dedup.ts --outdir ./dist --target node --format esm --packages external && bun run build:types",
|
|
38
43
|
"build:types": "tsc -p tsconfig.build.json",
|
|
39
44
|
"typecheck": "tsc --noEmit",
|
|
40
45
|
"test": "bun test",
|
|
@@ -69,6 +74,7 @@
|
|
|
69
74
|
"@atcute/identity": "^2.0.2",
|
|
70
75
|
"@atcute/identity-resolver": "^2.0.1",
|
|
71
76
|
"@atcute/password-session": "^1.0.2",
|
|
77
|
+
"@noble/hashes": "^2.3.0",
|
|
72
78
|
"classic-level": "^3.0.0"
|
|
73
79
|
}
|
|
74
80
|
}
|
package/src/agent.ts
CHANGED
|
@@ -325,7 +325,7 @@ export class Agent {
|
|
|
325
325
|
const res = await this.rpc.post("com.atproto.repo.createRecord" as never, {
|
|
326
326
|
input: { repo: this.did, collection, record: { ...record, $type: collection } },
|
|
327
327
|
} as never);
|
|
328
|
-
if (!res.ok) throw new RockskyError(res.data);
|
|
328
|
+
if (!res.ok) throw new RockskyError(res.data, res.status);
|
|
329
329
|
return (res.data as { uri: string }).uri;
|
|
330
330
|
}
|
|
331
331
|
|
|
@@ -334,7 +334,7 @@ export class Agent {
|
|
|
334
334
|
const res = await this.rpc.post("com.atproto.repo.putRecord" as never, {
|
|
335
335
|
input: { repo: this.did, collection, rkey, record: { ...record, $type: collection } },
|
|
336
336
|
} as never);
|
|
337
|
-
if (!res.ok) throw new RockskyError(res.data);
|
|
337
|
+
if (!res.ok) throw new RockskyError(res.data, res.status);
|
|
338
338
|
return (res.data as { uri: string }).uri;
|
|
339
339
|
}
|
|
340
340
|
|
|
@@ -344,7 +344,7 @@ export class Agent {
|
|
|
344
344
|
const res = await this.rpc.post("com.atproto.repo.deleteRecord" as never, {
|
|
345
345
|
input: { repo: this.did, collection, rkey },
|
|
346
346
|
} as never);
|
|
347
|
-
if (!res.ok) throw new RockskyError(res.data);
|
|
347
|
+
if (!res.ok) throw new RockskyError(res.data, res.status);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
/**
|