Skip to content

Commit 11f3191

Browse files
authored
Update README.md
Signed-off-by: Ethan Winters <ebwinters@comcast.net>
1 parent e858427 commit 11f3191

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,48 @@
22
Complete typescript types and validation functions generated for the [lexicon-community lexicon schemas](https://github.com/lexicon-community/lexicon) using the [atproto lex-cli package](https://github.com/bluesky-social/atproto/tree/main/packages/lex-cli)
33

44
## Getting started
5-
TODO
5+
1. `npm install @lexicon-community/types`
66

77
## Usage
8-
TODO
8+
### Listing bookmarks
9+
```ts
10+
import {CommunityLexiconBookmarksBookmark} from '@lexicon-community/types'
11+
...
12+
let bookmarks: CommunityLexiconBookmarksBookmark.Record[] = []
13+
const promises = [
14+
accumulate(cursor =>
15+
agent.com.atproto.repo
16+
.listRecords({
17+
repo: agent!.did ?? '',
18+
collection: 'community.lexicon.bookmarks.bookmark',
19+
cursor,
20+
})
21+
.then(res => ({
22+
cursor: res.data.cursor,
23+
items: res.data.records,
24+
})),
25+
),
26+
]
27+
28+
const resultset = await Promise.all(promises)
29+
for (const res of resultset) {
30+
for (let bookmark of res) {
31+
const isValid =
32+
CommunityLexiconBookmarksBookmark.isRecord(bookmark.value) &&
33+
CommunityLexiconBookmarksBookmark.validateRecord(bookmark.value)
34+
.success
35+
if (isValid) {
36+
const recordVal =
37+
bookmark.value as CommunityLexiconBookmarksBookmark.Record
38+
bookmarks.push(recordVal)
39+
}
40+
}
41+
}
42+
return bookmarks
43+
```
944

1045
## Generating types from the [Lexicons repo](https://github.com/lexicon-community/lexicon)
1146

1247
1. Setup the [ATProto repo](https://github.com/bluesky-social/atproto) locally
1348
2. `cd path_to_atproto_repo\atproto\packages\lex-cli`
14-
3. `npx lex gen-api path_to_this_repo\tpyes\community\lexicon\your_lexicon path_to_lexicon_repo\community\lexicon\your_lexicon\your_schema.json`
49+
3. `npx lex gen-api path_to_this_repo\tpyes\community\lexicon\your_lexicon path_to_lexicon_repo\community\lexicon\your_lexicon\your_schema.json`

0 commit comments

Comments
 (0)