Skip to content

Commit 4bfcaf2

Browse files
fix: corrected the example
1 parent dc8f479 commit 4bfcaf2

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

examples/user-profile/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@tailwindcss/vite": "^4.0.12",
18+
"@tsky/lexicons": "workspace:*",
1819
"@types/react": "^19.0.10",
1920
"@types/react-dom": "^19.0.4",
2021
"@vitejs/plugin-react": "^4.3.4",
@@ -24,4 +25,4 @@
2425
"typescript-eslint": "^8.24.1",
2526
"vite": "^6.2.0"
2627
}
27-
}
28+
}

examples/user-profile/src/App.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
import { type ActorProfile, createAgent } from '@tsky/client';
2+
import type { At } from '@tsky/lexicons';
23
import { useEffect, useState } from 'react';
34

4-
async function findUser(user: string) {
5+
async function getUserProfile(identity: string) {
56
try {
67
const agent = await createAgent({
78
options: {
89
service: 'https://public.api.bsky.app',
910
},
1011
});
11-
const actor = await agent.actor(user);
12+
13+
let did = identity;
14+
15+
if (!did.startsWith('did:')) {
16+
const _id = await agent.resolveDIDFromHandle(identity);
17+
did = _id.did;
18+
}
19+
20+
const actor = await agent.actor(did as At.DID);
1221

1322
return actor.profile();
1423
} catch (err) {
1524
console.error(err);
1625
}
1726
}
1827

19-
// did:plc:xdwatsttsxnl5h65mf3ddxbq
20-
2128
function App() {
2229
const [search, setSearch] = useState<string>();
2330
const [user, setUser] = useState<ActorProfile>();
2431

2532
useEffect(() => {
2633
if (search) {
27-
findUser(search).then(setUser);
34+
getUserProfile(search).then(setUser);
2835
}
2936
}, [search]);
3037

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"scripts": {
1414
"dev": "pnpm run -r dev",
1515
"build": "pnpm run -r build",
16+
"prepare": "pnpm --filter !@tsky/docs build",
1617
"docs:dev": "pnpm run --filter @tsky/docs dev",
1718
"docs:build": "pnpm run --filter @tsky/docs build",
1819
"docs:preview": "pnpm run --filter @tsky/docs preview",
@@ -34,4 +35,4 @@
3435
"biome check --write --"
3536
]
3637
}
37-
}
38+
}

packages/client/src/agent.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,4 +1305,13 @@ export class Agent {
13051305

13061306
return data;
13071307
}
1308+
1309+
async resolveDIDFromHandle(handle: string, options: RPCOptions = {}) {
1310+
return this.client
1311+
.get('com.atproto.identity.resolveHandle', {
1312+
params: { handle },
1313+
...options,
1314+
})
1315+
.then((res) => res.data);
1316+
}
13081317
}

packages/lexicons/src/lib/lexicons.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* @module
66
* Contains type declarations for Bluesky lexicons
77
* @generated
8-
* Generated on: 2025-03-01T03:33:31.541Z
8+
* Generated on: 2025-03-11T19:48:30.798Z
99
* Version: main
10-
* Source: https://github.com/bluesky-social/atproto/tree/38320191e559f8b928c6e951a9b4a6207240bfc1/lexicons
10+
* Source: https://github.com/bluesky-social/atproto/tree/18fbfa00057dda9ef4eba77d8b4e87994893c952/lexicons
1111
*/
1212

1313
/** Base type with optional type field */
@@ -612,6 +612,7 @@ export declare namespace AppBskyEmbedRecordWithMedia {
612612

613613
export declare namespace AppBskyEmbedVideo {
614614
interface Main extends TypedBase {
615+
/** The mp4 video file. May be up to 100mb, formerly limited to 50mb. */
615616
video: At.Blob;
616617
/**
617618
* Alt text description of the video, for accessibility.
@@ -5468,6 +5469,7 @@ export declare namespace ToolsOzoneTeamListMembers {
54685469
* \@default 50
54695470
*/
54705471
limit?: number;
5472+
q?: string;
54715473
roles?: string[];
54725474
}
54735475
type Input = undefined;

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)