-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathstarterpack.ts
More file actions
64 lines (56 loc) · 1.42 KB
/
starterpack.ts
File metadata and controls
64 lines (56 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type {
AppBskyGraphGetStarterPack,
AppBskyGraphGetStarterPacks,
} from '@tsky/lexicons';
import type { Client } from '~/agent/client';
import type { RPCOptions } from '~/types';
import { Paginator } from '~/utils';
export class StarterPack {
constructor(private client: Client) {}
/**
* Gets a view of a starter pack.
*/
view(
uri: string,
options: RPCOptions,
): Promise<AppBskyGraphGetStarterPack.Output>;
/**
* Get views for a list of starter packs.
*/
view(
uris: string[],
options: RPCOptions,
): Promise<AppBskyGraphGetStarterPacks.Output['starterPacks']>;
async view(uris: string | string[], options: RPCOptions) {
if (Array.isArray(uris)) {
const res = await this.client.get('app.bsky.graph.getStarterPacks', {
params: {
uris,
},
...options,
});
return res.data.starterPacks;
}
const res = await this.client.get('app.bsky.graph.getStarterPack', {
params: { starterPack: uris },
...options,
});
return res.data;
}
/**
* Search for starter packs.
*/
search(query: string, limit?: number, options?: RPCOptions) {
return Paginator.init(async (cursor) => {
const res = await this.client.get('app.bsky.graph.searchStarterPacks', {
params: {
cursor,
q: query,
limit,
},
...options,
});
return res.data;
});
}
}