Skip to content

Commit 41ed726

Browse files
committed
chore: apply new biome format
1 parent 8a4a2b5 commit 41ed726

File tree

27 files changed

+1746
-1746
lines changed

27 files changed

+1746
-1746
lines changed

packages/client/src/bsky/feed.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
import type {
2-
AppBskyFeedGetFeed,
3-
AppBskyFeedGetTimeline,
4-
} from '@tsky/lexicons';
5-
import type { Client } from '~/tsky/client';
6-
import { Paginator } from '~/tsky/paginator';
7-
8-
export class Feed {
9-
constructor(private client: Client) {}
10-
11-
/**
12-
* Get a hydrated feed from an actor's selected feed generator. Implemented by App View.
13-
*/
14-
async getFeed(
15-
params: AppBskyFeedGetFeed.Params,
16-
options?: AppBskyFeedGetFeed.Input,
17-
): Promise<Paginator<AppBskyFeedGetFeed.Output>> {
18-
return Paginator.init(async (cursor) => {
19-
const res = await this.client.get('app.bsky.feed.getFeed', {
20-
...(options ?? {}),
21-
params: {
22-
cursor,
23-
...params,
24-
},
25-
});
26-
27-
return res.data;
28-
});
29-
}
30-
31-
/**
32-
* Get a view of the requesting account's home timeline. This is expected to be some form of reverse-chronological feed.
33-
*/
34-
getTimeline(
35-
params: AppBskyFeedGetTimeline.Params,
36-
options?: AppBskyFeedGetTimeline.Input,
37-
): Promise<Paginator<AppBskyFeedGetTimeline.Output>> {
38-
return Paginator.init(async (cursor) => {
39-
const res = await this.client.get('app.bsky.feed.getTimeline', {
40-
...(options ?? {}),
41-
params: {
42-
cursor,
43-
...params,
44-
},
45-
});
46-
47-
return res.data;
48-
});
49-
}
50-
}
1+
import type {
2+
AppBskyFeedGetFeed,
3+
AppBskyFeedGetTimeline,
4+
} from '@tsky/lexicons';
5+
import type { Client } from '~/tsky/client';
6+
import { Paginator } from '~/tsky/paginator';
7+
8+
export class Feed {
9+
constructor(private client: Client) {}
10+
11+
/**
12+
* Get a hydrated feed from an actor's selected feed generator. Implemented by App View.
13+
*/
14+
async getFeed(
15+
params: AppBskyFeedGetFeed.Params,
16+
options?: AppBskyFeedGetFeed.Input,
17+
): Promise<Paginator<AppBskyFeedGetFeed.Output>> {
18+
return Paginator.init(async (cursor) => {
19+
const res = await this.client.get('app.bsky.feed.getFeed', {
20+
...(options ?? {}),
21+
params: {
22+
cursor,
23+
...params,
24+
},
25+
});
26+
27+
return res.data;
28+
});
29+
}
30+
31+
/**
32+
* Get a view of the requesting account's home timeline. This is expected to be some form of reverse-chronological feed.
33+
*/
34+
getTimeline(
35+
params: AppBskyFeedGetTimeline.Params,
36+
options?: AppBskyFeedGetTimeline.Input,
37+
): Promise<Paginator<AppBskyFeedGetTimeline.Output>> {
38+
return Paginator.init(async (cursor) => {
39+
const res = await this.client.get('app.bsky.feed.getTimeline', {
40+
...(options ?? {}),
41+
params: {
42+
cursor,
43+
...params,
44+
},
45+
});
46+
47+
return res.data;
48+
});
49+
}
50+
}

packages/client/src/bsky/index.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import type { AppBskyActorDefs } from '@tsky/lexicons';
2-
import { Feed } from '~/bsky/feed';
3-
import type { Client } from '~/tsky/client';
4-
5-
export class Bsky {
6-
client: Client;
7-
8-
constructor(client: Client) {
9-
this.client = client;
10-
}
11-
12-
/**
13-
* Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth.
14-
*/
15-
async profile(
16-
identifier: string,
17-
): Promise<AppBskyActorDefs.ProfileViewDetailed> {
18-
const res = await this.client.get('app.bsky.actor.getProfile', {
19-
params: { actor: identifier },
20-
});
21-
22-
return res.data;
23-
}
24-
25-
get feed() {
26-
return new Feed(this.client);
27-
}
28-
}
1+
import type { AppBskyActorDefs } from '@tsky/lexicons';
2+
import { Feed } from '~/bsky/feed';
3+
import type { Client } from '~/tsky/client';
4+
5+
export class Bsky {
6+
client: Client;
7+
8+
constructor(client: Client) {
9+
this.client = client;
10+
}
11+
12+
/**
13+
* Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth.
14+
*/
15+
async profile(
16+
identifier: string,
17+
): Promise<AppBskyActorDefs.ProfileViewDetailed> {
18+
const res = await this.client.get('app.bsky.actor.getProfile', {
19+
params: { actor: identifier },
20+
});
21+
22+
return res.data;
23+
}
24+
25+
get feed() {
26+
return new Feed(this.client);
27+
}
28+
}

packages/client/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './bsky';
2-
export * from './tsky';
1+
export * from './bsky';
2+
export * from './tsky';

packages/client/src/tsky/client.ts

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
import type {
2-
RPCOptions,
3-
XRPC,
4-
XRPCRequestOptions,
5-
XRPCResponse,
6-
} from '@atcute/client';
7-
import type { Procedures, Queries } from '@tsky/lexicons';
8-
9-
// From @atcute/client
10-
type OutputOf<T> = T extends {
11-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
12-
output: any;
13-
}
14-
? T['output']
15-
: never;
16-
17-
export class Client<Q = Queries, P = Procedures> {
18-
xrpc: XRPC;
19-
20-
constructor(xrpc: XRPC) {
21-
this.xrpc = xrpc;
22-
}
23-
24-
/**
25-
* Makes a query (GET) request
26-
* @param nsid Namespace ID of a query endpoint
27-
* @param options Options to include like parameters
28-
* @returns The response of the request
29-
*/
30-
async get<K extends keyof Q>(
31-
nsid: K,
32-
options: RPCOptions<Q[K]>,
33-
): Promise<XRPCResponse<OutputOf<Q[K]>>> {
34-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
35-
return this.xrpc.get(nsid as any, options);
36-
}
37-
38-
/**
39-
* Makes a procedure (POST) request
40-
* @param nsid Namespace ID of a procedure endpoint
41-
* @param options Options to include like input body or parameters
42-
* @returns The response of the request
43-
*/
44-
async call<K extends keyof P>(
45-
nsid: K,
46-
options: RPCOptions<P[K]>,
47-
): Promise<XRPCResponse<OutputOf<P[K]>>> {
48-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
49-
return this.xrpc.call(nsid as any, options);
50-
}
51-
52-
/** Makes a request to the XRPC service */
53-
async request(options: XRPCRequestOptions): Promise<XRPCResponse> {
54-
return this.xrpc.request(options);
55-
}
56-
}
1+
import type {
2+
RPCOptions,
3+
XRPC,
4+
XRPCRequestOptions,
5+
XRPCResponse,
6+
} from '@atcute/client';
7+
import type { Procedures, Queries } from '@tsky/lexicons';
8+
9+
// From @atcute/client
10+
type OutputOf<T> = T extends {
11+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
12+
output: any;
13+
}
14+
? T['output']
15+
: never;
16+
17+
export class Client<Q = Queries, P = Procedures> {
18+
xrpc: XRPC;
19+
20+
constructor(xrpc: XRPC) {
21+
this.xrpc = xrpc;
22+
}
23+
24+
/**
25+
* Makes a query (GET) request
26+
* @param nsid Namespace ID of a query endpoint
27+
* @param options Options to include like parameters
28+
* @returns The response of the request
29+
*/
30+
async get<K extends keyof Q>(
31+
nsid: K,
32+
options: RPCOptions<Q[K]>,
33+
): Promise<XRPCResponse<OutputOf<Q[K]>>> {
34+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
35+
return this.xrpc.get(nsid as any, options);
36+
}
37+
38+
/**
39+
* Makes a procedure (POST) request
40+
* @param nsid Namespace ID of a procedure endpoint
41+
* @param options Options to include like input body or parameters
42+
* @returns The response of the request
43+
*/
44+
async call<K extends keyof P>(
45+
nsid: K,
46+
options: RPCOptions<P[K]>,
47+
): Promise<XRPCResponse<OutputOf<P[K]>>> {
48+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
49+
return this.xrpc.call(nsid as any, options);
50+
}
51+
52+
/** Makes a request to the XRPC service */
53+
async request(options: XRPCRequestOptions): Promise<XRPCResponse> {
54+
return this.xrpc.request(options);
55+
}
56+
}

packages/client/src/tsky/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './paginator';
2-
export * from './tsky';
1+
export * from './paginator';
2+
export * from './tsky';
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
interface CursorResponse {
2-
cursor?: string;
3-
}
4-
5-
export class Paginator<T extends CursorResponse> {
6-
readonly values: T[] = [];
7-
8-
private constructor(
9-
private onNext: (cursor?: string) => Promise<T>,
10-
defaultValues?: T[],
11-
) {
12-
if (defaultValues) {
13-
this.values = defaultValues;
14-
}
15-
}
16-
17-
static async init<T extends CursorResponse>(
18-
onNext: (cursor?: string) => Promise<T>,
19-
defaultValues?: T[],
20-
): Promise<Paginator<T>> {
21-
const paginator = new Paginator<T>(onNext, defaultValues);
22-
23-
// load the first page
24-
await paginator.next();
25-
26-
return paginator;
27-
}
28-
29-
clone() {
30-
return new Paginator(this.onNext, this.values);
31-
}
32-
33-
async next() {
34-
const hasValues = this.values.length > 0;
35-
36-
const cursor = hasValues
37-
? this.values[this.values.length - 1].cursor
38-
: undefined;
39-
40-
// When we are at the end of the list
41-
if (hasValues && !cursor) return null;
42-
43-
const data = await this.onNext(cursor);
44-
45-
this.values.push(data);
46-
47-
return data;
48-
}
49-
}
1+
interface CursorResponse {
2+
cursor?: string;
3+
}
4+
5+
export class Paginator<T extends CursorResponse> {
6+
readonly values: T[] = [];
7+
8+
private constructor(
9+
private onNext: (cursor?: string) => Promise<T>,
10+
defaultValues?: T[],
11+
) {
12+
if (defaultValues) {
13+
this.values = defaultValues;
14+
}
15+
}
16+
17+
static async init<T extends CursorResponse>(
18+
onNext: (cursor?: string) => Promise<T>,
19+
defaultValues?: T[],
20+
): Promise<Paginator<T>> {
21+
const paginator = new Paginator<T>(onNext, defaultValues);
22+
23+
// load the first page
24+
await paginator.next();
25+
26+
return paginator;
27+
}
28+
29+
clone() {
30+
return new Paginator(this.onNext, this.values);
31+
}
32+
33+
async next() {
34+
const hasValues = this.values.length > 0;
35+
36+
const cursor = hasValues
37+
? this.values[this.values.length - 1].cursor
38+
: undefined;
39+
40+
// When we are at the end of the list
41+
if (hasValues && !cursor) return null;
42+
43+
const data = await this.onNext(cursor);
44+
45+
this.values.push(data);
46+
47+
return data;
48+
}
49+
}

0 commit comments

Comments
 (0)