@atcute/bluesky 1.0.7 → 1.0.8
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.
- package/README.md +63 -2
- package/lib/lexicons.ts +2842 -0
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
# @atcute/bluesky
|
|
2
2
|
|
|
3
|
-
[Bluesky](https://bsky.app) type definitions for `@atcute/client`, a lightweight and cute API client
|
|
3
|
+
[Bluesky](https://bsky.app) type definitions for `@atcute/client`, a lightweight and cute API client
|
|
4
|
+
for AT Protocol.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## usage
|
|
7
|
+
|
|
8
|
+
you'd need to import `@atcute/bluesky/lexicons` into your project, either by adding it into the
|
|
9
|
+
`types` field in `tsconfig.json` or by importing it on your source code.
|
|
10
|
+
|
|
11
|
+
```jsonc
|
|
12
|
+
// tsconfig.json
|
|
13
|
+
{
|
|
14
|
+
"compilerOptions": {
|
|
15
|
+
"types": ["@atcute/bluesky/lexicons"],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// env.d.ts
|
|
22
|
+
/// <reference types="@atcute/bluesky/lexicons" />
|
|
23
|
+
```
|
|
6
24
|
|
|
7
25
|
```ts
|
|
26
|
+
// index.ts
|
|
8
27
|
import '@atcute/bluesky/lexicons';
|
|
9
28
|
```
|
|
29
|
+
|
|
30
|
+
newly added lexicons are augmented to `@atcute/client/lexicons` module
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import type { AppBskyFeedPost, AppBskyRichtextFacet, Brand } from '@atcute/client/lexicons';
|
|
34
|
+
|
|
35
|
+
type Facet = AppBskyRichtextFacet.Main;
|
|
36
|
+
type MentionFeature = Brand.Union<AppBskyRichtextFacet.Mention>;
|
|
37
|
+
|
|
38
|
+
const mention: MentionFeature = {
|
|
39
|
+
$type: 'app.bsky.richtext.facet#mention',
|
|
40
|
+
did: 'did:plc:z72i7hdynmk6r22z27h6tvur',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const facet: Facet = {
|
|
44
|
+
index: {
|
|
45
|
+
byteStart: 6,
|
|
46
|
+
byteEnd: 15,
|
|
47
|
+
},
|
|
48
|
+
features: [mention],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const record: AppBskyFeedPost.Record = {
|
|
52
|
+
$type: 'app.bsky.feed.post',
|
|
53
|
+
text: `hello @bsky.app!`,
|
|
54
|
+
facets: [facet],
|
|
55
|
+
createdAt: new Date().toISOString(),
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const rpc = new XRPC({ handle: simpleFetchHandler({ service: 'https://api.bsky.app' }) });
|
|
61
|
+
|
|
62
|
+
const { data } = await rpc.get('app.bsky.actor.getProfile', {
|
|
63
|
+
params: {
|
|
64
|
+
actor: 'did:plc:z72i7hdynmk6r22z27h6tvur',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
data;
|
|
69
|
+
// -> { handle: 'bsky.app', displayName: 'Bluesky', ... }
|
|
70
|
+
```
|