@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 CHANGED
@@ -109,10 +109,12 @@ SHA-256, identical to the server and every other Rocksky SDK.
109
109
  ## Duplicate prevention + real-time sync
110
110
 
111
111
  An optional local index (embedded [classic-level](https://github.com/Level/classic-level)
112
- LevelDB) prevents duplicate writes and stays live off the firehose:
112
+ LevelDB) prevents duplicate writes and stays live off the firehose. It is
113
+ Node-only, so it lives on its own subpath — the main `@rocksky/sdk` entry stays
114
+ browser-safe:
113
115
 
114
116
  ```ts
115
- import { RockskyIndex } from "@rocksky/sdk";
117
+ import { RockskyIndex } from "@rocksky/sdk/dedup";
116
118
 
117
119
  const idx = new RockskyIndex("./dedup");
118
120
  await idx.open();
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Filter } from "./filter.js";
2
2
  import { RockskyLibrary } from "./library.js";
3
- import type { ActorProfileViewBasic, ActorProfileViewDetailed, AlbumViewBasic, AlbumViewDetailed, ArtistViewBasic, ArtistViewDetailed, ChartsView, FeedGeneratorsView, FeedRecommendationsView, FeedRecommendedAlbumsView, FeedRecommendedArtistsView, FeedSearchResultsView, FeedStoriesView, FeedView, GetActorCompatibilityOutput, GetActorNeighboursOutput, GetActorPlaylistsOutput, GetAlbumShoutsOutput, GetApikeysOutput, GetArtistListenersOutput, GetArtistRecentListenersOutput, GetArtistShoutsOutput, GetFeedGeneratorOutput, GetMirrorSourcesOutput, GetProfileShoutsOutput, GetShoutRepliesOutput, GetSongRecentListenersOutput, GetTrackShoutsOutput, GetUnreadCountOutput, ListNotificationsOutput, PlayerCurrentlyPlayingViewDetailed, PlayerPlaybackQueueViewDetailed, PlaylistGetPlaylistsOutput, PlaylistViewDetailed, RockboxSettingsView, ScrobbleViewBasic, SongViewBasic, SongViewDetailed, StatsGlobalStatsView, StatsView, StatsWrappedView, UpdateSeenOutput } from "./generated/types.js";
3
+ import type { ActorProfileViewBasic, ActorProfileViewDetailed, AlbumViewBasic, AlbumViewDetailed, ArtistViewBasic, ArtistViewDetailed, ChartsView, CreateScrobbleInput, FollowAccountOutput, FeedGeneratorsView, FeedRecommendationsView, FeedRecommendedAlbumsView, FeedRecommendedArtistsView, FeedSearchResultsView, FeedStoriesView, FeedView, GetActorCompatibilityOutput, GetActorNeighboursOutput, GetActorPlaylistsOutput, GetAlbumShoutsOutput, GetApikeysOutput, GetArtistListenersOutput, GetArtistRecentListenersOutput, GetArtistShoutsOutput, GetFeedGeneratorOutput, GetMirrorSourcesOutput, GetProfileShoutsOutput, GetShoutRepliesOutput, GetSongRecentListenersOutput, GetTrackShoutsOutput, GetUnreadCountOutput, ListNotificationsOutput, MirrorSourceView, PlayerCurrentlyPlayingViewDetailed, PlayerPlaybackQueueViewDetailed, PlaylistGetPlaylistsOutput, PlaylistViewDetailed, PutAudioSettingsInput, PutMirrorSourceInput, RockboxSettingsView, ScrobbleViewBasic, SongViewBasic, SongViewDetailed, StatsGlobalStatsView, StatsView, StatsWrappedView, PlaylistCreatePlaylistOutput, PlaylistUpdatePlaylistOutput, AddSongsOutput, UnfollowAccountOutput, UpdateSeenOutput } from "./generated/types.js";
4
4
  /**
5
5
  * A typed date window for the `top*` charts. Build one with the {@link Interval}
6
6
  * factories; `range` bounds are RFC-3339 datetimes.
@@ -51,6 +51,13 @@ export declare class RockskyClient {
51
51
  /** Call any AppView read query by nsid; returns the raw JSON response. Every
52
52
  * method here is sugar over this — use it for queries without a wrapper. */
53
53
  get(nsid: string, params?: Record<string, unknown>): Promise<unknown>;
54
+ /** Call any AppView procedure by nsid. `params` ride the query string (some
55
+ * procedures take their arguments there), `body` is the JSON input — omitted
56
+ * entirely when `undefined`. Escape hatch for procedures without a wrapper. */
57
+ post<T = unknown>(nsid: string, opts?: {
58
+ params?: Record<string, unknown>;
59
+ body?: unknown;
60
+ }): Promise<T>;
54
61
  /** An actor's most-played songs. */
55
62
  songs(actor: string, limit?: number, offset?: number): Promise<SongViewBasic[]>;
56
63
  /** An actor's loved (liked) songs. */
@@ -165,6 +172,35 @@ export declare class RockskyClient {
165
172
  playlists(limit?: number, offset?: number): Promise<PlaylistGetPlaylistsOutput>;
166
173
  /** A single playlist with its items. */
167
174
  playlist(uri: string): Promise<PlaylistViewDetailed>;
175
+ /**
176
+ * Create a playlist (`app.rocksky.playlist.createPlaylist`). Auth required.
177
+ * Publishes an app.rocksky.playlist record to the caller's repo; the AppView
178
+ * only lists it once the commit has been ingested.
179
+ */
180
+ createPlaylist(input: {
181
+ name: string;
182
+ description?: string;
183
+ pictureUrl?: string;
184
+ }): Promise<PlaylistCreatePlaylistOutput>;
185
+ /** Rename or re-describe a playlist (`app.rocksky.playlist.updatePlaylist`). Owner only. */
186
+ updatePlaylist(input: {
187
+ uri: string;
188
+ name?: string;
189
+ description?: string;
190
+ pictureUrl?: string;
191
+ }): Promise<PlaylistUpdatePlaylistOutput>;
192
+ /**
193
+ * Add songs to a playlist (`app.rocksky.playlist.addSongs`). Owner only.
194
+ * `songs` are app.rocksky.song AT-URIs; returns the created entry URIs.
195
+ */
196
+ addSongs(uri: string, songs: string[]): Promise<AddSongsOutput>;
197
+ /** Delete a playlist and the caller's own entries (`app.rocksky.playlist.removePlaylist`). Owner only. */
198
+ removePlaylist(uri: string): Promise<void>;
199
+ /**
200
+ * Remove a song from a playlist (`app.rocksky.playlist.removeTrack`). An
201
+ * entry can only be retracted by the repo that published it.
202
+ */
203
+ removeTrack(uri: string, songUri: string): Promise<void>;
168
204
  /** Shouts on an album. */
169
205
  albumShouts(uri: string, limit?: number, offset?: number): Promise<GetAlbumShoutsOutput>;
170
206
  /** Shouts on an artist. */
@@ -188,5 +224,17 @@ export declare class RockskyClient {
188
224
  * to mark **all** of the viewer's notifications. Returns the number remaining
189
225
  * unread. */
190
226
  updateSeen(ids?: string[]): Promise<UpdateSeenOutput>;
227
+ /** Follow an account by DID or handle (`app.rocksky.graph.followAccount`). Auth required. */
228
+ followAccount(account: string): Promise<FollowAccountOutput>;
229
+ /** Unfollow an account by DID or handle (`app.rocksky.graph.unfollowAccount`). Auth required. */
230
+ unfollowAccount(account: string): Promise<UnfollowAccountOutput>;
231
+ /** Submit a scrobble through the AppView (`app.rocksky.scrobble.createScrobble`).
232
+ * Auth required. For direct-to-PDS scrobbling use {@link Agent} instead. */
233
+ createScrobble(input: CreateScrobbleInput): Promise<ScrobbleViewBasic>;
234
+ /** Create or update a mirror source (`app.rocksky.mirror.putMirrorSource`). Auth required. */
235
+ putMirrorSource(input: PutMirrorSourceInput): Promise<MirrorSourceView>;
236
+ /** Patch the viewer's Rockbox audio settings (`app.rocksky.rockbox.putAudioSettings`).
237
+ * Auth required. */
238
+ putAudioSettings(input: PutAudioSettingsInput): Promise<RockboxSettingsView>;
191
239
  }
192
240
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,EACf,QAAQ,EAGR,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EAEvB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,mB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BAAgB,CAAC;IAM1D,4DAA4D;IAC5D,WAAW,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAG5C;4DACwD;IACxD,aAAa,CAAC,KAAK,SAAK,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAG5E;;iBAEa;IACP,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ3D,6FAA6F;IAC7F,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI5D,iGAAiG;IACjG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhE;gFAC4E;IAC5E,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAItE,8FAA8F;IAC9F,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIvE;wBACoB;IACpB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAG7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
package/dist/dedup.js ADDED
@@ -0,0 +1,215 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
+
17
+ // src/dedup.ts
18
+ import { fromUint8Array } from "@atcute/car";
19
+ import { decode as cborDecode, fromBytes, isBytes, isCidLink } from "@atcute/cbor";
20
+ import { toString as cidToString } from "@atcute/cid";
21
+ import { ClassicLevel } from "classic-level";
22
+
23
+ // src/hash.ts
24
+ import { sha256 } from "@noble/hashes/sha2.js";
25
+ import { bytesToHex } from "@noble/hashes/utils.js";
26
+ function sha256Lower(s) {
27
+ return bytesToHex(sha256(new TextEncoder().encode(s.toLowerCase())));
28
+ }
29
+ function songHash(title, artist, album) {
30
+ return sha256Lower(`${title} - ${artist} - ${album}`);
31
+ }
32
+ function albumHash(album, albumArtist) {
33
+ return sha256Lower(`${album} - ${albumArtist}`);
34
+ }
35
+ function artistHash(albumArtist) {
36
+ return sha256Lower(albumArtist);
37
+ }
38
+
39
+ // src/dedup.ts
40
+ var C_ARTIST = "app.rocksky.artist";
41
+ var C_ALBUM = "app.rocksky.album";
42
+ var C_SONG = "app.rocksky.song";
43
+ var C_SCROBBLE = "app.rocksky.scrobble";
44
+ var SEP = "\x00";
45
+ function totalIndexed(s) {
46
+ return s.artists + s.albums + s.songs + s.scrobbles;
47
+ }
48
+ function identKey(did, col, hash) {
49
+ return `${did}${SEP}${col}${SEP}${hash}`;
50
+ }
51
+ function scrobbleKey(did, songH, secs) {
52
+ return `${did}${SEP}${C_SCROBBLE}${SEP}${songH}${SEP}${secs}`;
53
+ }
54
+ function primaryFor(did, col, rec) {
55
+ const s = (k) => typeof rec[k] === "string" ? rec[k] : "";
56
+ switch (col) {
57
+ case C_ARTIST:
58
+ return s("name") ? identKey(did, C_ARTIST, artistHash(s("name"))) : undefined;
59
+ case C_ALBUM:
60
+ return s("title") && s("artist") ? identKey(did, C_ALBUM, albumHash(s("title"), s("artist"))) : undefined;
61
+ case C_SONG:
62
+ return s("title") && s("artist") && s("album") ? identKey(did, C_SONG, songHash(s("title"), s("artist"), s("album"))) : undefined;
63
+ case C_SCROBBLE: {
64
+ if (s("title") && s("artist") && s("album") && s("createdAt")) {
65
+ const secs = Math.floor(Date.parse(s("createdAt")) / 1000);
66
+ if (!Number.isNaN(secs))
67
+ return scrobbleKey(did, songHash(s("title"), s("artist"), s("album")), secs);
68
+ }
69
+ return;
70
+ }
71
+ }
72
+ return;
73
+ }
74
+
75
+ class RockskyIndex {
76
+ db;
77
+ constructor(path) {
78
+ this.db = new ClassicLevel(path, { keyEncoding: "utf8", valueEncoding: "utf8" });
79
+ }
80
+ open() {
81
+ return this.db.open();
82
+ }
83
+ close() {
84
+ return this.db.close();
85
+ }
86
+ async get(key) {
87
+ try {
88
+ return await this.db.get(key);
89
+ } catch {
90
+ return;
91
+ }
92
+ }
93
+ songUri(did, title, artist, album) {
94
+ return this.get(identKey(did, C_SONG, songHash(title, artist, album)));
95
+ }
96
+ albumUri(did, album, albumArtist) {
97
+ return this.get(identKey(did, C_ALBUM, albumHash(album, albumArtist)));
98
+ }
99
+ artistUri(did, albumArtist) {
100
+ return this.get(identKey(did, C_ARTIST, artistHash(albumArtist)));
101
+ }
102
+ scrobbleUri(did, title, artist, album, secs) {
103
+ return this.get(scrobbleKey(did, songHash(title, artist, album), secs));
104
+ }
105
+ async putPrimary(did, col, primary, uri) {
106
+ const rkey = uri.slice(uri.lastIndexOf("/") + 1);
107
+ await this.db.batch([
108
+ { type: "put", key: primary, value: uri },
109
+ { type: "put", key: `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`, value: primary }
110
+ ]);
111
+ }
112
+ recordSong(did, title, artist, album, uri) {
113
+ return this.putPrimary(did, C_SONG, identKey(did, C_SONG, songHash(title, artist, album)), uri);
114
+ }
115
+ recordAlbum(did, album, albumArtist, uri) {
116
+ return this.putPrimary(did, C_ALBUM, identKey(did, C_ALBUM, albumHash(album, albumArtist)), uri);
117
+ }
118
+ recordArtist(did, albumArtist, uri) {
119
+ return this.putPrimary(did, C_ARTIST, identKey(did, C_ARTIST, artistHash(albumArtist)), uri);
120
+ }
121
+ recordScrobble(did, title, artist, album, secs, uri) {
122
+ return this.putPrimary(did, C_SCROBBLE, scrobbleKey(did, songHash(title, artist, album), secs), uri);
123
+ }
124
+ cursor(did) {
125
+ return this.get(`${SEP}meta${SEP}cursor${SEP}${did}`).then((v) => v ? Number(v) : 0);
126
+ }
127
+ async setCursor(did, timeUS) {
128
+ await this.db.put(`${SEP}meta${SEP}cursor${SEP}${did}`, String(timeUS));
129
+ }
130
+ async indexCar(did, car) {
131
+ const reader = fromUint8Array(car);
132
+ const blocks = new Map;
133
+ for (const entry of reader)
134
+ blocks.set(cidToString(entry.cid), entry.bytes);
135
+ const root = reader.roots[0];
136
+ if (!root)
137
+ throw new Error("CAR has no root");
138
+ const commit = cborDecode(blocks.get(root.$link));
139
+ const stats = { artists: 0, albums: 0, songs: 0, scrobbles: 0 };
140
+ const ops = [];
141
+ for (const [path, valueLink] of walkMst(blocks, commit.data.$link)) {
142
+ const slash = path.indexOf("/");
143
+ if (slash < 0)
144
+ continue;
145
+ const col = path.slice(0, slash);
146
+ const rkey = path.slice(slash + 1);
147
+ if (col !== C_ARTIST && col !== C_ALBUM && col !== C_SONG && col !== C_SCROBBLE)
148
+ continue;
149
+ const recBytes = blocks.get(valueLink);
150
+ if (!recBytes)
151
+ continue;
152
+ const rec = cborDecode(recBytes);
153
+ const primary = primaryFor(did, col, rec);
154
+ if (!primary)
155
+ continue;
156
+ const uri = `at://${did}/${col}/${rkey}`;
157
+ ops.push({ type: "put", key: primary, value: uri });
158
+ ops.push({ type: "put", key: `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`, value: primary });
159
+ if (col === C_ARTIST)
160
+ stats.artists++;
161
+ else if (col === C_ALBUM)
162
+ stats.albums++;
163
+ else if (col === C_SONG)
164
+ stats.songs++;
165
+ else
166
+ stats.scrobbles++;
167
+ }
168
+ if (commit.rev)
169
+ ops.push({ type: "put", key: `${SEP}meta${SEP}rev${SEP}${did}`, value: commit.rev });
170
+ await this.db.batch(ops);
171
+ return stats;
172
+ }
173
+ async applyCommit(did, col, operation, rkey, record) {
174
+ if (operation === "create" || operation === "update") {
175
+ if (!record)
176
+ return;
177
+ const primary = primaryFor(did, col, record);
178
+ if (!primary)
179
+ return;
180
+ await this.putPrimary(did, col, primary, `at://${did}/${col}/${rkey}`);
181
+ } else if (operation === "delete") {
182
+ const rk = `${SEP}rk${SEP}${did}${SEP}${col}${SEP}${rkey}`;
183
+ const primary = await this.get(rk);
184
+ if (primary) {
185
+ await this.db.batch([
186
+ { type: "del", key: primary },
187
+ { type: "del", key: rk }
188
+ ]);
189
+ }
190
+ }
191
+ }
192
+ }
193
+ function* walkMst(blocks, cid) {
194
+ const raw = blocks.get(cid);
195
+ if (!raw)
196
+ return;
197
+ const node = cborDecode(raw);
198
+ if (node.l && isCidLink(node.l))
199
+ yield* walkMst(blocks, node.l.$link);
200
+ let last = new Uint8Array(0);
201
+ for (const e of node.e) {
202
+ const suffix = isBytes(e.k) ? fromBytes(e.k) : e.k;
203
+ const key = new Uint8Array(e.p + suffix.length);
204
+ key.set(last.subarray(0, e.p), 0);
205
+ key.set(suffix, e.p);
206
+ yield [new TextDecoder().decode(key), e.v.$link];
207
+ last = key;
208
+ if (e.t && isCidLink(e.t))
209
+ yield* walkMst(blocks, e.t.$link);
210
+ }
211
+ }
212
+ export {
213
+ RockskyIndex,
214
+ totalIndexed
215
+ };
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- /** Error thrown when a Rocksky XRPC call returns a non-2xx `{ error, message }`. */
2
1
  export declare class RockskyError extends Error {
2
+ /** The XRPC error code (e.g. "InvalidRequest", "AuthMissing"), when the
3
+ * server sent one. */
3
4
  readonly kind?: string;
4
- constructor(payload: unknown);
5
+ /** The HTTP status of the failed response, when known. */
6
+ readonly status?: number;
7
+ constructor(payload: unknown, status?: number);
5
8
  }
6
9
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBACX,OAAO,EAAE,OAAO;CAM7B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC;0BACsB;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;CAO9C"}
@@ -114,6 +114,16 @@ export interface AddItemsToQueueParams {
114
114
  /** Whether to shuffle the added items in the queue */
115
115
  shuffle?: boolean;
116
116
  }
117
+ export interface AddSongsOutput {
118
+ /** AT-URIs of the created app.rocksky.playlist.song records */
119
+ uris: AtUri[];
120
+ }
121
+ export interface AddSongsParams {
122
+ /** The URI of the playlist to add the songs to */
123
+ uri: AtUri;
124
+ /** AT-URIs of the app.rocksky.song records to add */
125
+ songs: AtUri[];
126
+ }
117
127
  export interface AlbumGetAlbumParams {
118
128
  /** The URI of the album to retrieve. */
119
129
  uri: AtUri;
@@ -677,10 +687,12 @@ export interface GetActorPlaylistsOutput {
677
687
  export interface GetActorPlaylistsParams {
678
688
  /** The DID or handle of the actor */
679
689
  did: AtIdentifier;
680
- /** The maximum number of albums to return */
690
+ /** The maximum number of playlists to return */
681
691
  limit?: number;
682
692
  /** The offset for pagination */
683
693
  offset?: number;
694
+ /** RSQL filter expression, e.g. `name=="Road trip*";track.artist=="Daft Punk"`. Supports ==, !=, <, <=, >, >=, =in=, =out=, and `;`/`and`, `,`/`or` combinators, `*` wildcards in string values. Filterable fields: name, title, description, uri, spotifyLink, tidalLink, appleMusicLink, createdAt, updatedAt. The `track.title`, `track.artist`, `track.album` and `track.albumArtist` selectors match the playlist's contents, returning playlists that contain a matching track; several `track.*` terms joined with `;` must all be satisfied by the same track. */
695
+ filter?: string;
684
696
  }
685
697
  export interface GetActorScrobblesOutput {
686
698
  scrobbles?: ScrobbleViewBasic[];
@@ -1309,6 +1321,20 @@ export interface LibrarySearchParams {
1309
1321
  /** Song result offset. */
1310
1322
  songOffset?: number;
1311
1323
  }
1324
+ export interface LibraryUpdatePlaylistInput {
1325
+ /** The playlist id to update. */
1326
+ playlistId: string;
1327
+ /** New playlist name. */
1328
+ name?: string;
1329
+ /** New playlist comment. */
1330
+ comment?: string;
1331
+ /** A song id to add to the playlist. */
1332
+ songIdToAdd?: string;
1333
+ /** A track index to remove from the playlist. */
1334
+ songIndexToRemove?: number;
1335
+ }
1336
+ export interface LibraryUpdatePlaylistOutput {
1337
+ }
1312
1338
  export interface LikeRecord {
1313
1339
  /** The date when the like was created. */
1314
1340
  createdAt: DateTime;
@@ -1443,15 +1469,25 @@ export interface PlayFileParams {
1443
1469
  playerId?: string;
1444
1470
  fileId: string;
1445
1471
  }
1472
+ export interface PlaylistCreatePlaylistOutput {
1473
+ /** The AT-URI of the created app.rocksky.playlist record. */
1474
+ uri: AtUri;
1475
+ /** The CID of the created app.rocksky.playlist record. */
1476
+ cid: string;
1477
+ }
1446
1478
  export interface PlaylistCreatePlaylistParams {
1447
1479
  /** The name of the playlist */
1448
1480
  name: string;
1449
1481
  /** A brief description of the playlist */
1450
1482
  description?: string;
1483
+ /** The URL of the cover image for the playlist */
1484
+ pictureUrl?: Uri;
1451
1485
  }
1452
1486
  export interface PlaylistGetPlaylistParams {
1453
1487
  /** The URI of the playlist to retrieve. */
1454
1488
  uri: AtUri;
1489
+ /** RSQL filter expression applied to the playlist's tracks, e.g. `artist=="Daft Punk";duration=gt=200000`. Supports ==, !=, <, <=, >, >=, =in=, =out=, and `;`/`and`, `,`/`or` combinators, `*` wildcards in string values. Filterable fields: title, artist, album, albumArtist, genre, composer, label, duration, trackNumber, discNumber, mbId, isrc, sha256, uri, albumUri, artistUri, addedAt */
1490
+ filter?: string;
1455
1491
  }
1456
1492
  export interface PlaylistGetPlaylistsOutput {
1457
1493
  playlists?: PlaylistViewBasic[];
@@ -1461,14 +1497,8 @@ export interface PlaylistGetPlaylistsParams {
1461
1497
  limit?: number;
1462
1498
  /** The offset for pagination, used to skip a number of playlists. */
1463
1499
  offset?: number;
1464
- }
1465
- export interface PlaylistItemRecord {
1466
- subject: StrongRef;
1467
- /** The date the playlist was created. */
1468
- createdAt: DateTime;
1469
- track: SongViewBasic;
1470
- /** The order of the item in the playlist. */
1471
- order: number;
1500
+ /** RSQL filter expression, e.g. `name=="Road trip*";track.artist=="Daft Punk"`. Supports ==, !=, <, <=, >, >=, =in=, =out=, and `;`/`and`, `,`/`or` combinators, `*` wildcards in string values. Filterable fields: name, title, description, uri, spotifyLink, tidalLink, appleMusicLink, createdAt, updatedAt, curatorDid, curatorHandle, curatorName. The `track.title`, `track.artist`, `track.album` and `track.albumArtist` selectors match the playlist's contents, returning playlists that contain a matching track; several `track.*` terms joined with `;` must all be satisfied by the same track. */
1501
+ filter?: string;
1472
1502
  }
1473
1503
  export interface PlaylistRecord {
1474
1504
  /** The name of the playlist. */
@@ -1490,6 +1520,42 @@ export interface PlaylistRecord {
1490
1520
  /** The Apple Music link of the playlist. */
1491
1521
  appleMusicLink?: string;
1492
1522
  }
1523
+ export interface PlaylistSongRecord {
1524
+ /** Strong reference (AT-URI + CID) to the parent app.rocksky.playlist record. */
1525
+ playlist: StrongRef;
1526
+ /** Strong reference (AT-URI + CID) to the app.rocksky.song record this entry points at. */
1527
+ song: StrongRef;
1528
+ /** The title of the song. */
1529
+ title: string;
1530
+ /** The artist of the song. */
1531
+ artist: string;
1532
+ /** The album the song belongs to. */
1533
+ album: string;
1534
+ /** The album artist of the song. */
1535
+ albumArtist: string;
1536
+ /** The duration of the song in milliseconds. */
1537
+ duration: number;
1538
+ /** The URL of the album art of the song. */
1539
+ albumArtUrl?: Uri;
1540
+ /** The date and time the song was added to the playlist. */
1541
+ addedAt: DateTime;
1542
+ }
1543
+ export interface PlaylistUpdatePlaylistOutput {
1544
+ /** The AT-URI of the updated app.rocksky.playlist record. */
1545
+ uri: AtUri;
1546
+ /** The CID of the updated app.rocksky.playlist record. */
1547
+ cid: string;
1548
+ }
1549
+ export interface PlaylistUpdatePlaylistParams {
1550
+ /** The URI of the playlist to update */
1551
+ uri: AtUri;
1552
+ /** The new name of the playlist */
1553
+ name?: string;
1554
+ /** The new description of the playlist */
1555
+ description?: string;
1556
+ /** The new cover image URL for the playlist */
1557
+ pictureUrl?: Uri;
1558
+ }
1493
1559
  /** Basic view of a playlist, including its metadata */
1494
1560
  export interface PlaylistViewBasic {
1495
1561
  /** The unique identifier of the playlist. */
@@ -1514,6 +1580,8 @@ export interface PlaylistViewBasic {
1514
1580
  createdAt?: DateTime;
1515
1581
  /** The number of tracks in the playlist. */
1516
1582
  trackCount?: number;
1583
+ /** Album-art URLs of up to four of the playlist's tracks, for rendering a cover mosaic when the playlist has no picture of its own. */
1584
+ trackArts?: Uri[];
1517
1585
  }
1518
1586
  /** Detailed view of a playlist, including its tracks and metadata */
1519
1587
  export interface PlaylistViewDetailed {
@@ -1632,8 +1700,8 @@ export interface RemoveShoutParams {
1632
1700
  export interface RemoveTrackParams {
1633
1701
  /** The URI of the playlist to remove the track from */
1634
1702
  uri: AtUri;
1635
- /** The position of the track to remove in the playlist */
1636
- position: number;
1703
+ /** The URI of the app.rocksky.song record to remove from the playlist */
1704
+ songUri: AtUri;
1637
1705
  }
1638
1706
  export interface ReplyShoutInput {
1639
1707
  /** The unique identifier of the shout to reply to */
@@ -2353,20 +2421,6 @@ export interface UpdateNowPlayingInput {
2353
2421
  }
2354
2422
  export interface UpdateNowPlayingOutput {
2355
2423
  }
2356
- export interface UpdatePlaylistInput {
2357
- /** The playlist id to update. */
2358
- playlistId: string;
2359
- /** New playlist name. */
2360
- name?: string;
2361
- /** New playlist comment. */
2362
- comment?: string;
2363
- /** A song id to add to the playlist. */
2364
- songIdToAdd?: string;
2365
- /** A track index to remove from the playlist. */
2366
- songIndexToRemove?: number;
2367
- }
2368
- export interface UpdatePlaylistOutput {
2369
- }
2370
2424
  export interface UpdateSeenInput {
2371
2425
  /** The ids of the notifications to mark as viewed. Omit to mark all. */
2372
2426
  ids?: string[];
@@ -2469,7 +2523,7 @@ export interface Endpoints {
2469
2523
  "app.rocksky.library.startScan": StartScanOutput;
2470
2524
  "app.rocksky.library.unstar": UnstarOutput;
2471
2525
  "app.rocksky.library.updateNowPlaying": UpdateNowPlayingOutput;
2472
- "app.rocksky.library.updatePlaylist": UpdatePlaylistOutput;
2526
+ "app.rocksky.library.updatePlaylist": LibraryUpdatePlaylistOutput;
2473
2527
  "app.rocksky.like.dislikeShout": ShoutView;
2474
2528
  "app.rocksky.like.dislikeSong": SongViewDetailed;
2475
2529
  "app.rocksky.like.likeShout": ShoutView;
@@ -2490,7 +2544,8 @@ export interface Endpoints {
2490
2544
  "app.rocksky.player.playFile": void;
2491
2545
  "app.rocksky.player.previous": void;
2492
2546
  "app.rocksky.player.seek": void;
2493
- "app.rocksky.playlist.createPlaylist": void;
2547
+ "app.rocksky.playlist.addSongs": AddSongsOutput;
2548
+ "app.rocksky.playlist.createPlaylist": PlaylistCreatePlaylistOutput;
2494
2549
  "app.rocksky.playlist.getPlaylist": PlaylistViewDetailed;
2495
2550
  "app.rocksky.playlist.getPlaylists": PlaylistGetPlaylistsOutput;
2496
2551
  "app.rocksky.playlist.insertDirectory": void;
@@ -2498,6 +2553,7 @@ export interface Endpoints {
2498
2553
  "app.rocksky.playlist.removePlaylist": void;
2499
2554
  "app.rocksky.playlist.removeTrack": void;
2500
2555
  "app.rocksky.playlist.startPlaylist": void;
2556
+ "app.rocksky.playlist.updatePlaylist": PlaylistUpdatePlaylistOutput;
2501
2557
  "app.rocksky.rockbox.getAudioSettings": RockboxSettingsView;
2502
2558
  "app.rocksky.rockbox.putAudioSettings": RockboxSettingsView;
2503
2559
  "app.rocksky.scrobble.createScrobble": ScrobbleViewBasic;