Skip to content

Commit f44ca01

Browse files
committed
chore: migrate to latest atcute libs including @atcute/lexicons
1 parent 3ce1493 commit f44ca01

File tree

8 files changed

+617
-563
lines changed

8 files changed

+617
-563
lines changed

examples/user-page/src/App.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { type ActorProfile, createAgent } from '@tsky/client';
2-
import type { At } from '@tsky/lexicons';
1+
import { type ActorProfile, createAgent, isDid } from '@tsky/client';
32
import { useEffect, useState } from 'react';
43

54
async function getUserProfile(identity: string) {
@@ -12,12 +11,12 @@ async function getUserProfile(identity: string) {
1211

1312
let did = identity;
1413

15-
if (!did.startsWith('did:')) {
14+
if (!isDid(did)) {
1615
const _id = await agent.resolveDIDFromHandle(identity);
1716
did = _id.did;
1817
}
1918

20-
const actor = await agent.actor(did as At.DID);
19+
const actor = await agent.actor(did);
2120

2221
return actor.profile();
2322
} catch (err) {

examples/user-profile/src/App.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { type ActorProfile, createAgent } from '@tsky/client';
2-
import type { At } from '@tsky/lexicons';
1+
import { type ActorProfile, createAgent, isDid } from '@tsky/client';
32
import { useEffect, useState } from 'react';
43

54
async function getUserProfile(identity: string) {
@@ -12,12 +11,12 @@ async function getUserProfile(identity: string) {
1211

1312
let did = identity;
1413

15-
if (!did.startsWith('did:')) {
14+
if (!isDid(did)) {
1615
const _id = await agent.resolveDIDFromHandle(identity);
1716
did = _id.did;
1817
}
1918

20-
const actor = await agent.actor(did as At.DID);
19+
const actor = await agent.actor(did);
2120

2221
return actor.profile();
2322
} catch (err) {

packages/client/globalSetup.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import fs from 'node:fs/promises';
22

33
import type { TestProject } from 'vitest/node';
44

5-
import { CredentialManager, XRPC } from '@atcute/client';
5+
import type { ComAtprotoRepoUploadBlob } from '@atcute/atproto';
6+
import { Client, CredentialManager } from '@atcute/client';
7+
import type { ActorIdentifier, Handle } from '@atcute/lexicons';
68
import { TestNetwork } from '@atproto/dev-env';
79

810
declare module 'vitest' {
@@ -21,7 +23,7 @@ export async function setup(project: TestProject) {
2123
);
2224

2325
const manager = new CredentialManager({ service: network.pds.url });
24-
const rpc = new XRPC({
26+
const rpc = new Client({
2527
handler: manager,
2628
});
2729

@@ -44,9 +46,9 @@ export async function teardown() {
4446
await network.close();
4547
}
4648

47-
const createAccount = async (rpc: XRPC, handle: string) => {
48-
await rpc.call('com.atproto.server.createAccount', {
49-
data: {
49+
const createAccount = async (rpc: Client, handle: Handle) => {
50+
await rpc.post('com.atproto.server.createAccount', {
51+
input: {
5052
handle: handle,
5153
email: `${handle}@example.com`,
5254
password: 'password',
@@ -55,15 +57,15 @@ const createAccount = async (rpc: XRPC, handle: string) => {
5557
console.log(`🙋 Created new account: @${handle}`);
5658
};
5759

58-
async function createProfileRecord(rpc: XRPC, handle: string) {
60+
async function createProfileRecord(rpc: Client, handle: ActorIdentifier) {
5961
const imageBuffer = await fs.readFile('alice-avatar.jpeg');
60-
const { data: blob } = await rpc.call('com.atproto.repo.uploadBlob', {
62+
const { data: blob } = (await rpc.post('com.atproto.repo.uploadBlob', {
6163
headers: { 'content-type': 'image/jpeg' },
62-
data: imageBuffer,
63-
});
64+
input: imageBuffer,
65+
})) as { data: ComAtprotoRepoUploadBlob.$output };
6466

65-
await rpc.call('com.atproto.repo.createRecord', {
66-
data: {
67+
await rpc.post('com.atproto.repo.createRecord', {
68+
input: {
6769
repo: handle,
6870
collection: 'app.bsky.actor.profile',
6971
record: {
@@ -77,9 +79,9 @@ async function createProfileRecord(rpc: XRPC, handle: string) {
7779
});
7880
}
7981

80-
async function createSamplePosts(rpc: XRPC, handle: string) {
81-
await rpc.call('com.atproto.repo.createRecord', {
82-
data: {
82+
async function createSamplePosts(rpc: Client, handle: ActorIdentifier) {
83+
await rpc.post('com.atproto.repo.createRecord', {
84+
input: {
8385
repo: handle,
8486
collection: 'app.bsky.feed.post',
8587
record: {

0 commit comments

Comments
 (0)