Bluesky type definitions for @atcute/client
, a lightweight and cute API client
for AT Protocol.
you'd need to import @atcute/bluesky/lexicons
into your project, either by adding it into the
types
field in tsconfig.json
or by importing it on your source code.
// tsconfig.json
{
"compilerOptions": {
"types": ["@atcute/bluesky/lexicons"],
},
}
// env.d.ts
/// <reference types="@atcute/bluesky/lexicons" />
// index.ts
import '@atcute/bluesky/lexicons';
newly added lexicons are augmented to @atcute/client/lexicons
module
import type { AppBskyFeedPost, AppBskyRichtextFacet, Brand } from '@atcute/client/lexicons';
type Facet = AppBskyRichtextFacet.Main;
type MentionFeature = Brand.Union<AppBskyRichtextFacet.Mention>;
const mention: MentionFeature = {
$type: 'app.bsky.richtext.facet#mention',
did: 'did:plc:z72i7hdynmk6r22z27h6tvur',
};
const facet: Facet = {
index: {
byteStart: 6,
byteEnd: 15,
},
features: [mention],
};
const record: AppBskyFeedPost.Record = {
$type: 'app.bsky.feed.post',
text: `hello @bsky.app!`,
facets: [facet],
createdAt: new Date().toISOString(),
};
const rpc = new XRPC({ handler: simpleFetchHandler({ service: 'https://api.bsky.app' }) });
const { data } = await rpc.get('app.bsky.actor.getProfile', {
params: {
actor: 'did:plc:z72i7hdynmk6r22z27h6tvur',
},
});
data;
// -> { handle: 'bsky.app', displayName: 'Bluesky', ... }