@rocksky/sdk 0.1.0 → 0.2.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 +5 -0
- package/dist/client.d.ts +37 -28
- package/dist/client.d.ts.map +1 -1
- package/dist/generated/types.d.ts +1932 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/http.d.ts +3 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/namespaces/_helpers.d.ts +11 -5
- package/dist/namespaces/_helpers.d.ts.map +1 -1
- package/dist/namespaces/actor.d.ts +15 -25
- package/dist/namespaces/actor.d.ts.map +1 -1
- package/dist/namespaces/album.d.ts +7 -13
- package/dist/namespaces/album.d.ts.map +1 -1
- package/dist/namespaces/apikey.d.ts +9 -22
- package/dist/namespaces/apikey.d.ts.map +1 -1
- package/dist/namespaces/artist.d.ts +11 -26
- package/dist/namespaces/artist.d.ts.map +1 -1
- package/dist/namespaces/charts.d.ts +8 -20
- package/dist/namespaces/charts.d.ts.map +1 -1
- package/dist/namespaces/dropbox.d.ts +7 -14
- package/dist/namespaces/dropbox.d.ts.map +1 -1
- package/dist/namespaces/feed.d.ts +14 -33
- package/dist/namespaces/feed.d.ts.map +1 -1
- package/dist/namespaces/googledrive.d.ts +6 -11
- package/dist/namespaces/googledrive.d.ts.map +1 -1
- package/dist/namespaces/graph.d.ts +10 -23
- package/dist/namespaces/graph.d.ts.map +1 -1
- package/dist/namespaces/like.d.ts +8 -9
- package/dist/namespaces/like.d.ts.map +1 -1
- package/dist/namespaces/mirror.d.ts +6 -10
- package/dist/namespaces/mirror.d.ts.map +1 -1
- package/dist/namespaces/player.d.ts +14 -36
- package/dist/namespaces/player.d.ts.map +1 -1
- package/dist/namespaces/playlist.d.ts +11 -35
- package/dist/namespaces/playlist.d.ts.map +1 -1
- package/dist/namespaces/scrobble.d.ts +7 -38
- package/dist/namespaces/scrobble.d.ts.map +1 -1
- package/dist/namespaces/shout.d.ts +12 -33
- package/dist/namespaces/shout.d.ts.map +1 -1
- package/dist/namespaces/song.d.ts +9 -43
- package/dist/namespaces/song.d.ts.map +1 -1
- package/dist/namespaces/spotify.d.ts +9 -12
- package/dist/namespaces/spotify.d.ts.map +1 -1
- package/dist/namespaces/stats.d.ts +5 -9
- package/dist/namespaces/stats.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +50 -33
- package/src/generated/types.ts +2143 -0
- package/src/http.ts +5 -5
- package/src/index.ts +17 -17
- package/src/namespaces/_helpers.ts +23 -13
- package/src/namespaces/actor.ts +37 -33
- package/src/namespaces/album.ts +14 -14
- package/src/namespaces/apikey.ts +18 -18
- package/src/namespaces/artist.ts +26 -32
- package/src/namespaces/charts.ts +15 -24
- package/src/namespaces/dropbox.ts +19 -13
- package/src/namespaces/feed.ts +42 -36
- package/src/namespaces/googledrive.ts +15 -10
- package/src/namespaces/graph.ts +24 -25
- package/src/namespaces/like.ts +17 -11
- package/src/namespaces/mirror.ts +8 -12
- package/src/namespaces/player.ts +44 -46
- package/src/namespaces/playlist.ts +34 -24
- package/src/namespaces/scrobble.ts +14 -40
- package/src/namespaces/shout.ts +36 -27
- package/src/namespaces/song.ts +27 -48
- package/src/namespaces/spotify.ts +19 -15
- package/src/namespaces/stats.ts +11 -7
- package/src/pipe.ts +1 -1
- package/src/realtime.ts +2 -2
package/src/client.ts
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
import { buildConfig, type HttpClientConfig, xrpcCall } from "./http";
|
|
1
|
+
import { buildConfig, type HttpClientConfig, xrpcCall } from "./http.js";
|
|
2
|
+
import { makeCall } from "./namespaces/_helpers.js";
|
|
2
3
|
import {
|
|
3
4
|
type PaginateArgs,
|
|
4
5
|
paginate as paginateFn,
|
|
5
|
-
} from "./paginate";
|
|
6
|
+
} from "./paginate.js";
|
|
6
7
|
import {
|
|
7
8
|
RealtimeClient,
|
|
8
9
|
type RealtimeOptions,
|
|
9
10
|
createRealtimeClient,
|
|
10
|
-
} from "./realtime";
|
|
11
|
-
import { ActorNamespace } from "./namespaces/actor";
|
|
12
|
-
import { AlbumNamespace } from "./namespaces/album";
|
|
13
|
-
import { ApikeyNamespace } from "./namespaces/apikey";
|
|
14
|
-
import { ArtistNamespace } from "./namespaces/artist";
|
|
15
|
-
import { ChartsNamespace } from "./namespaces/charts";
|
|
16
|
-
import { DropboxNamespace } from "./namespaces/dropbox";
|
|
17
|
-
import { FeedNamespace } from "./namespaces/feed";
|
|
18
|
-
import { GoogleDriveNamespace } from "./namespaces/googledrive";
|
|
19
|
-
import { GraphNamespace } from "./namespaces/graph";
|
|
20
|
-
import { LikeNamespace } from "./namespaces/like";
|
|
21
|
-
import { MirrorNamespace } from "./namespaces/mirror";
|
|
22
|
-
import { PlayerNamespace } from "./namespaces/player";
|
|
23
|
-
import { PlaylistNamespace } from "./namespaces/playlist";
|
|
24
|
-
import { ScrobbleNamespace } from "./namespaces/scrobble";
|
|
25
|
-
import { ShoutNamespace } from "./namespaces/shout";
|
|
26
|
-
import { SongNamespace } from "./namespaces/song";
|
|
27
|
-
import { SpotifyNamespace } from "./namespaces/spotify";
|
|
28
|
-
import { StatsNamespace } from "./namespaces/stats";
|
|
29
|
-
import type {
|
|
11
|
+
} from "./realtime.js";
|
|
12
|
+
import { ActorNamespace } from "./namespaces/actor.js";
|
|
13
|
+
import { AlbumNamespace } from "./namespaces/album.js";
|
|
14
|
+
import { ApikeyNamespace } from "./namespaces/apikey.js";
|
|
15
|
+
import { ArtistNamespace } from "./namespaces/artist.js";
|
|
16
|
+
import { ChartsNamespace } from "./namespaces/charts.js";
|
|
17
|
+
import { DropboxNamespace } from "./namespaces/dropbox.js";
|
|
18
|
+
import { FeedNamespace } from "./namespaces/feed.js";
|
|
19
|
+
import { GoogleDriveNamespace } from "./namespaces/googledrive.js";
|
|
20
|
+
import { GraphNamespace } from "./namespaces/graph.js";
|
|
21
|
+
import { LikeNamespace } from "./namespaces/like.js";
|
|
22
|
+
import { MirrorNamespace } from "./namespaces/mirror.js";
|
|
23
|
+
import { PlayerNamespace } from "./namespaces/player.js";
|
|
24
|
+
import { PlaylistNamespace } from "./namespaces/playlist.js";
|
|
25
|
+
import { ScrobbleNamespace } from "./namespaces/scrobble.js";
|
|
26
|
+
import { ShoutNamespace } from "./namespaces/shout.js";
|
|
27
|
+
import { SongNamespace } from "./namespaces/song.js";
|
|
28
|
+
import { SpotifyNamespace } from "./namespaces/spotify.js";
|
|
29
|
+
import { StatsNamespace } from "./namespaces/stats.js";
|
|
30
|
+
import type { Endpoints } from "./generated/types.js";
|
|
30
31
|
import type {
|
|
31
32
|
AuthProvider,
|
|
32
33
|
ClientOptions,
|
|
33
34
|
FetchLike,
|
|
34
35
|
RequestOptions,
|
|
35
|
-
} from "./types";
|
|
36
|
+
} from "./types.js";
|
|
37
|
+
|
|
38
|
+
type XrpcOpts = {
|
|
39
|
+
params?: Record<string, unknown>;
|
|
40
|
+
body?: unknown;
|
|
41
|
+
requireAuth?: boolean;
|
|
42
|
+
} & RequestOptions;
|
|
36
43
|
|
|
37
44
|
export class RockskyClient {
|
|
38
45
|
readonly config: HttpClientConfig;
|
|
@@ -58,8 +65,7 @@ export class RockskyClient {
|
|
|
58
65
|
|
|
59
66
|
constructor(options: ClientOptions = {}) {
|
|
60
67
|
this.config = buildConfig(options);
|
|
61
|
-
const call
|
|
62
|
-
xrpcCall(this.config, nsid, method, opts ?? {});
|
|
68
|
+
const call = makeCall(this.config);
|
|
63
69
|
|
|
64
70
|
this.actor = new ActorNamespace(call);
|
|
65
71
|
this.album = new AlbumNamespace(call);
|
|
@@ -130,17 +136,28 @@ export class RockskyClient {
|
|
|
130
136
|
return paginateFn(args);
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Direct escape hatch — call any XRPC endpoint by NSID.
|
|
141
|
+
*
|
|
142
|
+
* Known NSIDs (string literals) are typed via the generated `Endpoints`
|
|
143
|
+
* map; arbitrary strings fall back to `unknown` (override with `<T>`).
|
|
144
|
+
*/
|
|
145
|
+
xrpc<K extends keyof Endpoints>(
|
|
146
|
+
nsid: K,
|
|
147
|
+
method?: "GET" | "POST",
|
|
148
|
+
opts?: XrpcOpts,
|
|
149
|
+
): Promise<Endpoints[K]>;
|
|
134
150
|
xrpc<T = unknown>(
|
|
151
|
+
nsid: string,
|
|
152
|
+
method?: "GET" | "POST",
|
|
153
|
+
opts?: XrpcOpts,
|
|
154
|
+
): Promise<T>;
|
|
155
|
+
xrpc(
|
|
135
156
|
nsid: string,
|
|
136
157
|
method: "GET" | "POST" = "GET",
|
|
137
|
-
opts: {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
requireAuth?: boolean;
|
|
141
|
-
} & RequestOptions = {},
|
|
142
|
-
): Promise<T> {
|
|
143
|
-
return xrpcCall<T>(this.config, nsid, method, opts);
|
|
158
|
+
opts: XrpcOpts = {},
|
|
159
|
+
): Promise<unknown> {
|
|
160
|
+
return xrpcCall(this.config, nsid, method, opts);
|
|
144
161
|
}
|
|
145
162
|
|
|
146
163
|
static builder(): RockskyClientBuilder {
|