@rocksky/sdk 0.2.2 → 0.4.0

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 (51) hide show
  1. package/README.md +44 -254
  2. package/dist/agent.d.ts +77 -0
  3. package/dist/agent.d.ts.map +1 -0
  4. package/dist/client.d.ts +26 -113
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/dedup.d.ts +38 -0
  7. package/dist/dedup.d.ts.map +1 -0
  8. package/dist/errors.d.ts +3 -23
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/generated/types.d.ts +113 -11
  11. package/dist/generated/types.d.ts.map +1 -1
  12. package/dist/hash.d.ts +7 -0
  13. package/dist/hash.d.ts.map +1 -0
  14. package/dist/index.d.ts +16 -17
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +6648 -1288
  17. package/dist/jetstream.d.ts +17 -0
  18. package/dist/jetstream.d.ts.map +1 -0
  19. package/package.json +15 -11
  20. package/src/agent.ts +232 -0
  21. package/src/client.ts +82 -226
  22. package/src/dedup.ts +207 -0
  23. package/src/errors.ts +6 -43
  24. package/src/generated/types.ts +122 -11
  25. package/src/hash.ts +22 -0
  26. package/src/index.ts +16 -86
  27. package/src/jetstream.ts +122 -0
  28. package/src/http.ts +0 -195
  29. package/src/namespaces/_helpers.ts +0 -27
  30. package/src/namespaces/actor.ts +0 -93
  31. package/src/namespaces/album.ts +0 -34
  32. package/src/namespaces/apikey.ts +0 -50
  33. package/src/namespaces/artist.ts +0 -68
  34. package/src/namespaces/charts.ts +0 -38
  35. package/src/namespaces/dropbox.ts +0 -53
  36. package/src/namespaces/feed.ts +0 -112
  37. package/src/namespaces/googledrive.ts +0 -41
  38. package/src/namespaces/graph.ts +0 -62
  39. package/src/namespaces/like.ts +0 -46
  40. package/src/namespaces/mirror.ts +0 -27
  41. package/src/namespaces/player.ts +0 -125
  42. package/src/namespaces/playlist.ts +0 -95
  43. package/src/namespaces/scrobble.ts +0 -41
  44. package/src/namespaces/shout.ts +0 -99
  45. package/src/namespaces/song.ts +0 -60
  46. package/src/namespaces/spotify.ts +0 -56
  47. package/src/namespaces/stats.ts +0 -27
  48. package/src/paginate.ts +0 -90
  49. package/src/pipe.ts +0 -146
  50. package/src/realtime.ts +0 -408
  51. package/src/types.ts +0 -41
@@ -0,0 +1,122 @@
1
+ import type { RockskyIndex } from "./dedup.js";
2
+
3
+ /** The four public Bluesky Jetstream servers. */
4
+ export const DEFAULT_JETSTREAM_SERVERS = [
5
+ "wss://jetstream1.us-east.bsky.network",
6
+ "wss://jetstream2.us-east.bsky.network",
7
+ "wss://jetstream1.us-west.bsky.network",
8
+ "wss://jetstream2.us-west.bsky.network",
9
+ ];
10
+
11
+ const RECONNECT_SLACK_US = 5_000_000;
12
+
13
+ export interface JetstreamOptions {
14
+ /** Servers to connect to at once (defaults to {@link DEFAULT_JETSTREAM_SERVERS}). */
15
+ servers?: string[];
16
+ /** Cancels the hydration and closes all connections when aborted. */
17
+ signal?: AbortSignal;
18
+ }
19
+
20
+ interface JetEvent {
21
+ did: string;
22
+ time_us: number;
23
+ kind: string;
24
+ commit?: {
25
+ operation: string;
26
+ collection: string;
27
+ rkey: string;
28
+ record?: Record<string, unknown>;
29
+ };
30
+ }
31
+
32
+ // A shared, mutable watermark — the highest time_us processed across sources.
33
+ interface Watermark {
34
+ v: number;
35
+ }
36
+
37
+ /**
38
+ * Hydrate `idx` from the Bluesky Jetstream firehose for `did`, connecting to
39
+ * every server at once, filtered to app.rocksky.* + this DID. A shared watermark
40
+ * de-duplicates the overlap between servers and is the reconnect cursor. Resolves
41
+ * when opts.signal aborts; each source reconnects with backoff.
42
+ */
43
+ export async function runJetstream(idx: RockskyIndex, did: string, opts: JetstreamOptions = {}): Promise<void> {
44
+ const servers = opts.servers ?? DEFAULT_JETSTREAM_SERVERS;
45
+ const wm: Watermark = { v: await idx.cursor(did) };
46
+ await Promise.all(servers.map((s) => sourceLoop(s, idx, did, wm, opts.signal)));
47
+ }
48
+
49
+ async function sourceLoop(server: string, idx: RockskyIndex, did: string, wm: Watermark, signal?: AbortSignal) {
50
+ while (!signal?.aborted) {
51
+ const cursor = Math.max(0, wm.v - RECONNECT_SLACK_US);
52
+ try {
53
+ await connect(subscribeURL(server, did, cursor), idx, did, wm, signal);
54
+ } catch {
55
+ // fall through to backoff
56
+ }
57
+ await sleep(2000, signal);
58
+ }
59
+ }
60
+
61
+ function connect(url: string, idx: RockskyIndex, did: string, wm: Watermark, signal?: AbortSignal): Promise<void> {
62
+ return new Promise<void>((resolve) => {
63
+ const ws = new WebSocket(url);
64
+ const onAbort = () => {
65
+ try {
66
+ ws.close();
67
+ } catch {
68
+ /* ignore */
69
+ }
70
+ };
71
+ signal?.addEventListener("abort", onAbort, { once: true });
72
+
73
+ const done = () => {
74
+ signal?.removeEventListener("abort", onAbort);
75
+ resolve();
76
+ };
77
+
78
+ ws.onmessage = (ev: MessageEvent) => {
79
+ let event: JetEvent;
80
+ try {
81
+ event = JSON.parse(typeof ev.data === "string" ? ev.data : String(ev.data));
82
+ } catch {
83
+ return;
84
+ }
85
+ if (event.kind !== "commit" || event.did !== did || !event.commit) return;
86
+ // Claim this event for exactly one source (single-threaded: set before await).
87
+ if (event.time_us <= wm.v) return;
88
+ wm.v = event.time_us;
89
+ const c = event.commit;
90
+ void idx
91
+ .applyCommit(event.did, c.collection, c.operation, c.rkey, c.record)
92
+ .then(() => idx.setCursor(did, event.time_us))
93
+ .catch(() => {});
94
+ };
95
+ ws.onclose = done;
96
+ ws.onerror = () => {
97
+ try {
98
+ ws.close();
99
+ } catch {
100
+ /* ignore */
101
+ }
102
+ done();
103
+ };
104
+ });
105
+ }
106
+
107
+ function subscribeURL(server: string, did: string, cursorUS: number): string {
108
+ let u = `${server.replace(/\/+$/, "")}/subscribe?wantedCollections=app.rocksky.*&wantedDids=${encodeURIComponent(did)}`;
109
+ if (cursorUS > 0) u += `&cursor=${cursorUS}`;
110
+ return u;
111
+ }
112
+
113
+ function sleep(ms: number, signal?: AbortSignal): Promise<void> {
114
+ return new Promise((resolve) => {
115
+ if (signal?.aborted) return resolve();
116
+ const t = setTimeout(resolve, ms);
117
+ signal?.addEventListener("abort", () => {
118
+ clearTimeout(t);
119
+ resolve();
120
+ }, { once: true });
121
+ });
122
+ }
package/src/http.ts DELETED
@@ -1,195 +0,0 @@
1
- import {
2
- RockskyAuthError,
3
- RockskyHttpError,
4
- RockskyTimeoutError,
5
- } from "./errors.js";
6
- import {
7
- type AuthProvider,
8
- DEFAULT_BASE_URL,
9
- type FetchLike,
10
- type RequestOptions,
11
- } from "./types.js";
12
-
13
- export type XrpcCallOptions = RequestOptions & {
14
- params?: object;
15
- body?: unknown;
16
- requireAuth?: boolean;
17
- };
18
-
19
- export type HttpClientConfig = {
20
- baseUrl: string;
21
- auth?: AuthProvider;
22
- fetch: FetchLike;
23
- headers: Record<string, string>;
24
- timeoutMs: number;
25
- retries: number;
26
- retryDelayMs: number;
27
- };
28
-
29
- export function buildConfig(opts: {
30
- baseUrl?: string;
31
- auth?: AuthProvider;
32
- fetch?: FetchLike;
33
- headers?: Record<string, string>;
34
- timeoutMs?: number;
35
- retries?: number;
36
- retryDelayMs?: number;
37
- userAgent?: string;
38
- }): HttpClientConfig {
39
- const headers: Record<string, string> = {
40
- accept: "application/json",
41
- ...(opts.userAgent ? { "user-agent": opts.userAgent } : {}),
42
- ...(opts.headers ?? {}),
43
- };
44
- return {
45
- baseUrl: stripTrailingSlash(opts.baseUrl ?? DEFAULT_BASE_URL),
46
- auth: opts.auth,
47
- fetch: opts.fetch ?? globalThis.fetch.bind(globalThis),
48
- headers,
49
- timeoutMs: opts.timeoutMs ?? 30_000,
50
- retries: opts.retries ?? 0,
51
- retryDelayMs: opts.retryDelayMs ?? 300,
52
- };
53
- }
54
-
55
- function stripTrailingSlash(url: string): string {
56
- return url.endsWith("/") ? url.slice(0, -1) : url;
57
- }
58
-
59
- async function resolveAuth(
60
- provider: AuthProvider | undefined | null,
61
- ): Promise<string | undefined> {
62
- if (provider == null) return undefined;
63
- if (typeof provider === "string") return provider;
64
- return await provider();
65
- }
66
-
67
- export function serializeParams(
68
- params: object | undefined,
69
- ): string {
70
- if (!params) return "";
71
- const usp = new URLSearchParams();
72
- for (const [k, v] of Object.entries(params as Record<string, unknown>)) {
73
- if (v == null) continue;
74
- if (Array.isArray(v)) {
75
- for (const item of v) {
76
- if (item == null) continue;
77
- usp.append(k, String(item));
78
- }
79
- } else if (typeof v === "boolean") {
80
- usp.append(k, v ? "true" : "false");
81
- } else {
82
- usp.append(k, String(v));
83
- }
84
- }
85
- const s = usp.toString();
86
- return s ? `?${s}` : "";
87
- }
88
-
89
- export async function xrpcCall<T>(
90
- config: HttpClientConfig,
91
- nsid: string,
92
- method: "GET" | "POST",
93
- opts: XrpcCallOptions = {},
94
- ): Promise<T> {
95
- const url =
96
- `${config.baseUrl}/xrpc/${nsid}` + serializeParams(opts.params);
97
-
98
- const timeoutMs = opts.timeoutMs ?? config.timeoutMs;
99
- const retries = opts.retries ?? config.retries;
100
-
101
- const headers: Record<string, string> = {
102
- ...config.headers,
103
- ...(opts.headers ?? {}),
104
- };
105
-
106
- const authProvider = opts.auth === undefined ? config.auth : opts.auth;
107
- const token = await resolveAuth(authProvider);
108
- if (token) {
109
- headers.authorization = `Bearer ${token}`;
110
- } else if (opts.requireAuth) {
111
- throw new RockskyAuthError(
112
- `${nsid} requires authentication — provide an "auth" token`,
113
- );
114
- }
115
-
116
- const init: RequestInit = {
117
- method,
118
- headers,
119
- signal: opts.signal,
120
- };
121
-
122
- if (method === "POST" && opts.body !== undefined) {
123
- headers["content-type"] = "application/json";
124
- init.body = JSON.stringify(opts.body);
125
- }
126
-
127
- let lastErr: unknown;
128
- for (let attempt = 0; attempt <= retries; attempt++) {
129
- try {
130
- return await runOnce<T>(config.fetch, url, init, timeoutMs);
131
- } catch (err) {
132
- lastErr = err;
133
- if (!isRetryable(err) || attempt === retries) throw err;
134
- await sleep(config.retryDelayMs * Math.pow(2, attempt));
135
- }
136
- }
137
- throw lastErr;
138
- }
139
-
140
- async function runOnce<T>(
141
- fetchImpl: FetchLike,
142
- url: string,
143
- init: RequestInit,
144
- timeoutMs: number,
145
- ): Promise<T> {
146
- const controller = new AbortController();
147
- const upstream = init.signal;
148
- const onAbort = () => controller.abort(upstream?.reason);
149
- upstream?.addEventListener("abort", onAbort, { once: true });
150
- const timer = setTimeout(() => controller.abort(), timeoutMs);
151
- try {
152
- const res = await fetchImpl(url, { ...init, signal: controller.signal });
153
- const text = await res.text();
154
- const body = parseMaybeJson(text);
155
- if (!res.ok) {
156
- throw new RockskyHttpError({
157
- status: res.status,
158
- statusText: res.statusText,
159
- url,
160
- body,
161
- });
162
- }
163
- return body as T;
164
- } catch (err) {
165
- if (err instanceof DOMException && err.name === "AbortError") {
166
- if (upstream?.aborted) throw err;
167
- throw new RockskyTimeoutError(timeoutMs);
168
- }
169
- throw err;
170
- } finally {
171
- clearTimeout(timer);
172
- upstream?.removeEventListener("abort", onAbort);
173
- }
174
- }
175
-
176
- function parseMaybeJson(text: string): unknown {
177
- if (!text) return null;
178
- try {
179
- return JSON.parse(text);
180
- } catch {
181
- return text;
182
- }
183
- }
184
-
185
- function isRetryable(err: unknown): boolean {
186
- if (err instanceof RockskyTimeoutError) return true;
187
- if (err instanceof RockskyHttpError) {
188
- return err.status >= 500 || err.status === 429;
189
- }
190
- return false;
191
- }
192
-
193
- function sleep(ms: number): Promise<void> {
194
- return new Promise((r) => setTimeout(r, ms));
195
- }
@@ -1,27 +0,0 @@
1
- import { type HttpClientConfig, xrpcCall } from "../http.js";
2
- import type { RequestOptions } from "../types.js";
3
- import type { Endpoints } from "../generated/types.js";
4
-
5
- type CallOpts = {
6
- params?: object;
7
- body?: unknown;
8
- requireAuth?: boolean;
9
- } & RequestOptions;
10
-
11
- export interface Call {
12
- <K extends keyof Endpoints>(
13
- nsid: K,
14
- method: "GET" | "POST",
15
- opts?: CallOpts,
16
- ): Promise<Endpoints[K]>;
17
- <T = unknown>(
18
- nsid: string,
19
- method: "GET" | "POST",
20
- opts?: CallOpts,
21
- ): Promise<T>;
22
- }
23
-
24
- export function makeCall(config: HttpClientConfig): Call {
25
- return ((nsid: string, method: "GET" | "POST", opts?: CallOpts) =>
26
- xrpcCall(config, nsid, method, opts ?? {})) as Call;
27
- }
@@ -1,93 +0,0 @@
1
- import type {
2
- GetActorAlbumsParams,
3
- GetActorArtistsParams,
4
- GetActorCompatibilityParams,
5
- GetActorLovedSongsParams,
6
- GetActorNeighboursParams,
7
- GetActorPlaylistsParams,
8
- GetActorScrobblesParams,
9
- GetActorSongsParams,
10
- GetProfileParams,
11
- } from "../generated/types.js";
12
- import type { RequestOptions } from "../types.js";
13
- import type { Call } from "./_helpers.js";
14
-
15
- export type { GetProfileParams };
16
- export type ActorPagedParams = GetActorScrobblesParams;
17
- export type ActorRangeParams = GetActorAlbumsParams;
18
-
19
- export class ActorNamespace {
20
- constructor(private readonly call: Call) {}
21
-
22
- getProfile(params: GetProfileParams = {}, opts?: RequestOptions) {
23
- return this.call("app.rocksky.actor.getProfile", "GET", {
24
- params,
25
- ...opts,
26
- });
27
- }
28
-
29
- getActorAlbums(params: GetActorAlbumsParams, opts?: RequestOptions) {
30
- return this.call("app.rocksky.actor.getActorAlbums", "GET", {
31
- params,
32
- ...opts,
33
- });
34
- }
35
-
36
- getActorArtists(params: GetActorArtistsParams, opts?: RequestOptions) {
37
- return this.call("app.rocksky.actor.getActorArtists", "GET", {
38
- params,
39
- ...opts,
40
- });
41
- }
42
-
43
- getActorSongs(params: GetActorSongsParams, opts?: RequestOptions) {
44
- return this.call("app.rocksky.actor.getActorSongs", "GET", {
45
- params,
46
- ...opts,
47
- });
48
- }
49
-
50
- getActorScrobbles(
51
- params: GetActorScrobblesParams,
52
- opts?: RequestOptions,
53
- ) {
54
- return this.call("app.rocksky.actor.getActorScrobbles", "GET", {
55
- params,
56
- ...opts,
57
- });
58
- }
59
-
60
- getActorLovedSongs(
61
- params: GetActorLovedSongsParams,
62
- opts?: RequestOptions,
63
- ) {
64
- return this.call("app.rocksky.actor.getActorLovedSongs", "GET", {
65
- params,
66
- ...opts,
67
- });
68
- }
69
-
70
- getActorPlaylists(
71
- params: GetActorPlaylistsParams,
72
- opts?: RequestOptions,
73
- ) {
74
- return this.call("app.rocksky.actor.getActorPlaylists", "GET", {
75
- params,
76
- ...opts,
77
- });
78
- }
79
-
80
- getActorNeighbours(params: GetActorNeighboursParams, opts?: RequestOptions) {
81
- return this.call("app.rocksky.actor.getActorNeighbours", "GET", {
82
- params,
83
- ...opts,
84
- });
85
- }
86
-
87
- getActorCompatibility(params: GetActorCompatibilityParams, opts?: RequestOptions) {
88
- return this.call("app.rocksky.actor.getActorCompatibility", "GET", {
89
- params,
90
- ...opts,
91
- });
92
- }
93
- }
@@ -1,34 +0,0 @@
1
- import type {
2
- GetAlbumParams,
3
- GetAlbumsParams,
4
- GetAlbumTracksParams,
5
- } from "../generated/types.js";
6
- import type { RequestOptions } from "../types.js";
7
- import type { Call } from "./_helpers.js";
8
-
9
- export type { GetAlbumsParams };
10
-
11
- export class AlbumNamespace {
12
- constructor(private readonly call: Call) {}
13
-
14
- getAlbum(params: GetAlbumParams, opts?: RequestOptions) {
15
- return this.call("app.rocksky.album.getAlbum", "GET", {
16
- params,
17
- ...opts,
18
- });
19
- }
20
-
21
- getAlbums(params: GetAlbumsParams = {}, opts?: RequestOptions) {
22
- return this.call("app.rocksky.album.getAlbums", "GET", {
23
- params,
24
- ...opts,
25
- });
26
- }
27
-
28
- getAlbumTracks(params: GetAlbumTracksParams, opts?: RequestOptions) {
29
- return this.call("app.rocksky.album.getAlbumTracks", "GET", {
30
- params,
31
- ...opts,
32
- });
33
- }
34
- }
@@ -1,50 +0,0 @@
1
- import type {
2
- CreateApikeyInput,
3
- GetApikeysParams,
4
- RemoveApikeyParams,
5
- UpdateApikeyInput,
6
- } from "../generated/types.js";
7
- import type { RequestOptions } from "../types.js";
8
- import type { Call } from "./_helpers.js";
9
-
10
- export type { CreateApikeyInput, UpdateApikeyInput };
11
- export type ListApikeysParams = GetApikeysParams;
12
-
13
- export class ApikeyNamespace {
14
- constructor(private readonly call: Call) {}
15
-
16
- getApikeys(
17
- params: ListApikeysParams = {},
18
- opts?: RequestOptions,
19
- ) {
20
- return this.call("app.rocksky.apikey.getApikeys", "GET", {
21
- params,
22
- requireAuth: true,
23
- ...opts,
24
- });
25
- }
26
-
27
- createApikey(input: CreateApikeyInput, opts?: RequestOptions) {
28
- return this.call("app.rocksky.apikey.createApikey", "POST", {
29
- body: input,
30
- requireAuth: true,
31
- ...opts,
32
- });
33
- }
34
-
35
- updateApikey(input: UpdateApikeyInput, opts?: RequestOptions) {
36
- return this.call("app.rocksky.apikey.updateApikey", "POST", {
37
- body: input,
38
- requireAuth: true,
39
- ...opts,
40
- });
41
- }
42
-
43
- removeApikey(params: RemoveApikeyParams, opts?: RequestOptions) {
44
- return this.call("app.rocksky.apikey.removeApikey", "POST", {
45
- params,
46
- requireAuth: true,
47
- ...opts,
48
- });
49
- }
50
- }
@@ -1,68 +0,0 @@
1
- import type {
2
- GetArtistAlbumsParams,
3
- GetArtistListenersParams,
4
- GetArtistParams,
5
- GetArtistRecentListenersParams,
6
- GetArtistsParams,
7
- GetArtistTracksParams,
8
- } from "../generated/types.js";
9
- import type { RequestOptions } from "../types.js";
10
- import type { Call } from "./_helpers.js";
11
-
12
- export type { GetArtistsParams, GetArtistTracksParams };
13
- export type ArtistListenersParams = GetArtistListenersParams;
14
-
15
- export class ArtistNamespace {
16
- constructor(private readonly call: Call) {}
17
-
18
- getArtist(params: GetArtistParams, opts?: RequestOptions) {
19
- return this.call("app.rocksky.artist.getArtist", "GET", {
20
- params,
21
- ...opts,
22
- });
23
- }
24
-
25
- getArtists(params: GetArtistsParams = {}, opts?: RequestOptions) {
26
- return this.call("app.rocksky.artist.getArtists", "GET", {
27
- params,
28
- ...opts,
29
- });
30
- }
31
-
32
- getArtistAlbums(params: GetArtistAlbumsParams, opts?: RequestOptions) {
33
- return this.call("app.rocksky.artist.getArtistAlbums", "GET", {
34
- params,
35
- ...opts,
36
- });
37
- }
38
-
39
- getArtistTracks(
40
- params: GetArtistTracksParams = {},
41
- opts?: RequestOptions,
42
- ) {
43
- return this.call("app.rocksky.artist.getArtistTracks", "GET", {
44
- params,
45
- ...opts,
46
- });
47
- }
48
-
49
- getArtistListeners(
50
- params: GetArtistListenersParams,
51
- opts?: RequestOptions,
52
- ) {
53
- return this.call("app.rocksky.artist.getArtistListeners", "GET", {
54
- params,
55
- ...opts,
56
- });
57
- }
58
-
59
- getArtistRecentListeners(
60
- params: GetArtistRecentListenersParams,
61
- opts?: RequestOptions,
62
- ) {
63
- return this.call("app.rocksky.artist.getArtistRecentListeners", "GET", {
64
- params,
65
- ...opts,
66
- });
67
- }
68
- }
@@ -1,38 +0,0 @@
1
- import type {
2
- GetScrobblesChartParams,
3
- GetTopArtistsParams,
4
- GetTopTracksParams,
5
- } from "../generated/types.js";
6
- import type { RequestOptions } from "../types.js";
7
- import type { Call } from "./_helpers.js";
8
-
9
- export type ScrobblesChartParams = GetScrobblesChartParams;
10
- export type TopChartParams = GetTopArtistsParams;
11
-
12
- export class ChartsNamespace {
13
- constructor(private readonly call: Call) {}
14
-
15
- getScrobblesChart(
16
- params: ScrobblesChartParams = {},
17
- opts?: RequestOptions,
18
- ) {
19
- return this.call("app.rocksky.charts.getScrobblesChart", "GET", {
20
- params,
21
- ...opts,
22
- });
23
- }
24
-
25
- getTopArtists(params: GetTopArtistsParams = {}, opts?: RequestOptions) {
26
- return this.call("app.rocksky.charts.getTopArtists", "GET", {
27
- params,
28
- ...opts,
29
- });
30
- }
31
-
32
- getTopTracks(params: GetTopTracksParams = {}, opts?: RequestOptions) {
33
- return this.call("app.rocksky.charts.getTopTracks", "GET", {
34
- params,
35
- ...opts,
36
- });
37
- }
38
- }
@@ -1,53 +0,0 @@
1
- import type {
2
- DownloadFileParams,
3
- GetFilesParams,
4
- GetMetadataParams,
5
- GetTemporaryLinkParams,
6
- } from "../generated/types.js";
7
- import type { RequestOptions } from "../types.js";
8
- import type { Call } from "./_helpers.js";
9
-
10
- export class DropboxNamespace {
11
- constructor(private readonly call: Call) {}
12
-
13
- getFiles(
14
- params: GetFilesParams = {},
15
- opts?: RequestOptions,
16
- ) {
17
- return this.call("app.rocksky.dropbox.getFiles", "GET", {
18
- params,
19
- requireAuth: true,
20
- ...opts,
21
- });
22
- }
23
-
24
- getMetadata(params: GetMetadataParams, opts?: RequestOptions) {
25
- return this.call("app.rocksky.dropbox.getMetadata", "GET", {
26
- params,
27
- requireAuth: true,
28
- ...opts,
29
- });
30
- }
31
-
32
- getTemporaryLink(
33
- params: GetTemporaryLinkParams,
34
- opts?: RequestOptions,
35
- ) {
36
- return this.call("app.rocksky.dropbox.getTemporaryLink", "GET", {
37
- params,
38
- requireAuth: true,
39
- ...opts,
40
- });
41
- }
42
-
43
- downloadFile(
44
- params: DownloadFileParams,
45
- opts?: RequestOptions,
46
- ) {
47
- return this.call("app.rocksky.dropbox.downloadFile", "GET", {
48
- params,
49
- requireAuth: true,
50
- ...opts,
51
- });
52
- }
53
- }