@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.
Files changed (74) hide show
  1. package/README.md +5 -0
  2. package/dist/client.d.ts +37 -28
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/generated/types.d.ts +1932 -0
  5. package/dist/generated/types.d.ts.map +1 -0
  6. package/dist/http.d.ts +3 -3
  7. package/dist/http.d.ts.map +1 -1
  8. package/dist/index.d.ts +17 -17
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +6 -1
  11. package/dist/namespaces/_helpers.d.ts +11 -5
  12. package/dist/namespaces/_helpers.d.ts.map +1 -1
  13. package/dist/namespaces/actor.d.ts +15 -25
  14. package/dist/namespaces/actor.d.ts.map +1 -1
  15. package/dist/namespaces/album.d.ts +7 -13
  16. package/dist/namespaces/album.d.ts.map +1 -1
  17. package/dist/namespaces/apikey.d.ts +9 -22
  18. package/dist/namespaces/apikey.d.ts.map +1 -1
  19. package/dist/namespaces/artist.d.ts +11 -26
  20. package/dist/namespaces/artist.d.ts.map +1 -1
  21. package/dist/namespaces/charts.d.ts +8 -20
  22. package/dist/namespaces/charts.d.ts.map +1 -1
  23. package/dist/namespaces/dropbox.d.ts +7 -14
  24. package/dist/namespaces/dropbox.d.ts.map +1 -1
  25. package/dist/namespaces/feed.d.ts +14 -33
  26. package/dist/namespaces/feed.d.ts.map +1 -1
  27. package/dist/namespaces/googledrive.d.ts +6 -11
  28. package/dist/namespaces/googledrive.d.ts.map +1 -1
  29. package/dist/namespaces/graph.d.ts +10 -23
  30. package/dist/namespaces/graph.d.ts.map +1 -1
  31. package/dist/namespaces/like.d.ts +8 -9
  32. package/dist/namespaces/like.d.ts.map +1 -1
  33. package/dist/namespaces/mirror.d.ts +6 -10
  34. package/dist/namespaces/mirror.d.ts.map +1 -1
  35. package/dist/namespaces/player.d.ts +14 -36
  36. package/dist/namespaces/player.d.ts.map +1 -1
  37. package/dist/namespaces/playlist.d.ts +11 -35
  38. package/dist/namespaces/playlist.d.ts.map +1 -1
  39. package/dist/namespaces/scrobble.d.ts +7 -38
  40. package/dist/namespaces/scrobble.d.ts.map +1 -1
  41. package/dist/namespaces/shout.d.ts +12 -33
  42. package/dist/namespaces/shout.d.ts.map +1 -1
  43. package/dist/namespaces/song.d.ts +9 -43
  44. package/dist/namespaces/song.d.ts.map +1 -1
  45. package/dist/namespaces/spotify.d.ts +9 -12
  46. package/dist/namespaces/spotify.d.ts.map +1 -1
  47. package/dist/namespaces/stats.d.ts +5 -9
  48. package/dist/namespaces/stats.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/client.ts +50 -33
  51. package/src/generated/types.ts +2143 -0
  52. package/src/http.ts +5 -5
  53. package/src/index.ts +17 -17
  54. package/src/namespaces/_helpers.ts +23 -13
  55. package/src/namespaces/actor.ts +37 -33
  56. package/src/namespaces/album.ts +14 -14
  57. package/src/namespaces/apikey.ts +18 -18
  58. package/src/namespaces/artist.ts +26 -32
  59. package/src/namespaces/charts.ts +15 -24
  60. package/src/namespaces/dropbox.ts +19 -13
  61. package/src/namespaces/feed.ts +42 -36
  62. package/src/namespaces/googledrive.ts +15 -10
  63. package/src/namespaces/graph.ts +24 -25
  64. package/src/namespaces/like.ts +17 -11
  65. package/src/namespaces/mirror.ts +8 -12
  66. package/src/namespaces/player.ts +44 -46
  67. package/src/namespaces/playlist.ts +34 -24
  68. package/src/namespaces/scrobble.ts +14 -40
  69. package/src/namespaces/shout.ts +36 -27
  70. package/src/namespaces/song.ts +27 -48
  71. package/src/namespaces/spotify.ts +19 -15
  72. package/src/namespaces/stats.ts +11 -7
  73. package/src/pipe.ts +1 -1
  74. 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 { Call } from "./namespaces/_helpers";
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: Call = (nsid, method, opts) =>
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
- /** Direct escape hatch — call any XRPC endpoint by NSID. */
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
- params?: Record<string, unknown>;
139
- body?: unknown;
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 {