@atproto/dev-env 0.0.0-spaces-alpha-20260818163953
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/CHANGELOG.md +3424 -0
- package/LICENSE.txt +7 -0
- package/README.md +39 -0
- package/bin.js +7 -0
- package/dist/bin-multi-pds.d.ts +2 -0
- package/dist/bin-multi-pds.d.ts.map +1 -0
- package/dist/bin-multi-pds.js +130 -0
- package/dist/bin-multi-pds.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +56 -0
- package/dist/bin.js.map +1 -0
- package/dist/bsky.d.ts +27 -0
- package/dist/bsky.d.ts.map +1 -0
- package/dist/bsky.js +165 -0
- package/dist/bsky.js.map +1 -0
- package/dist/bsync.d.ts +22 -0
- package/dist/bsync.d.ts.map +1 -0
- package/dist/bsync.js +54 -0
- package/dist/bsync.js.map +1 -0
- package/dist/const.d.ts +4 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +4 -0
- package/dist/const.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +10 -0
- package/dist/env.js.map +1 -0
- package/dist/feed-gen.d.ts +15 -0
- package/dist/feed-gen.d.ts.map +1 -0
- package/dist/feed-gen.js +73 -0
- package/dist/feed-gen.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/introspect.d.ts +22 -0
- package/dist/introspect.d.ts.map +1 -0
- package/dist/introspect.js +65 -0
- package/dist/introspect.js.map +1 -0
- package/dist/mock/data.d.ts +3 -0
- package/dist/mock/data.d.ts.map +1 -0
- package/dist/mock/data.js +46 -0
- package/dist/mock/data.js.map +1 -0
- package/dist/mock/img/blur-hash-avatar-b64.d.ts +3 -0
- package/dist/mock/img/blur-hash-avatar-b64.d.ts.map +1 -0
- package/dist/mock/img/blur-hash-avatar-b64.js +2 -0
- package/dist/mock/img/blur-hash-avatar-b64.js.map +1 -0
- package/dist/mock/img/labeled-img-b64.d.ts +3 -0
- package/dist/mock/img/labeled-img-b64.d.ts.map +1 -0
- package/dist/mock/img/labeled-img-b64.js +2 -0
- package/dist/mock/img/labeled-img-b64.js.map +1 -0
- package/dist/mock/index.d.ts +3 -0
- package/dist/mock/index.d.ts.map +1 -0
- package/dist/mock/index.js +574 -0
- package/dist/mock/index.js.map +1 -0
- package/dist/moderator-client.d.ts +58 -0
- package/dist/moderator-client.d.ts.map +1 -0
- package/dist/moderator-client.js +110 -0
- package/dist/moderator-client.js.map +1 -0
- package/dist/network-no-appview.d.ts +21 -0
- package/dist/network-no-appview.d.ts.map +1 -0
- package/dist/network-no-appview.js +74 -0
- package/dist/network-no-appview.js.map +1 -0
- package/dist/network.d.ts +32 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +190 -0
- package/dist/network.js.map +1 -0
- package/dist/ozone.d.ts +31 -0
- package/dist/ozone.d.ts.map +1 -0
- package/dist/ozone.js +254 -0
- package/dist/ozone.js.map +1 -0
- package/dist/pds.d.ts +23 -0
- package/dist/pds.d.ts.map +1 -0
- package/dist/pds.js +97 -0
- package/dist/pds.js.map +1 -0
- package/dist/plc.d.ts +14 -0
- package/dist/plc.d.ts.map +1 -0
- package/dist/plc.js +28 -0
- package/dist/plc.js.map +1 -0
- package/dist/seed/author-feed.d.ts +4 -0
- package/dist/seed/author-feed.d.ts.map +1 -0
- package/dist/seed/author-feed.js +50 -0
- package/dist/seed/author-feed.js.map +1 -0
- package/dist/seed/basic.d.ts +16 -0
- package/dist/seed/basic.d.ts.map +1 -0
- package/dist/seed/basic.js +113 -0
- package/dist/seed/basic.js.map +1 -0
- package/dist/seed/client.d.ts +151 -0
- package/dist/seed/client.d.ts.map +1 -0
- package/dist/seed/client.js +365 -0
- package/dist/seed/client.js.map +1 -0
- package/dist/seed/follows.d.ts +4 -0
- package/dist/seed/follows.d.ts.map +1 -0
- package/dist/seed/follows.js +55 -0
- package/dist/seed/follows.js.map +1 -0
- package/dist/seed/index.d.ts +11 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +11 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/seed/likes.d.ts +4 -0
- package/dist/seed/likes.d.ts.map +1 -0
- package/dist/seed/likes.js +37 -0
- package/dist/seed/likes.js.map +1 -0
- package/dist/seed/quotes.d.ts +4 -0
- package/dist/seed/quotes.d.ts.map +1 -0
- package/dist/seed/quotes.js +21 -0
- package/dist/seed/quotes.js.map +1 -0
- package/dist/seed/reposts.d.ts +4 -0
- package/dist/seed/reposts.d.ts.map +1 -0
- package/dist/seed/reposts.js +17 -0
- package/dist/seed/reposts.js.map +1 -0
- package/dist/seed/thread-v2.d.ts +227 -0
- package/dist/seed/thread-v2.d.ts.map +1 -0
- package/dist/seed/thread-v2.js +755 -0
- package/dist/seed/thread-v2.js.map +1 -0
- package/dist/seed/users-bulk.d.ts +3 -0
- package/dist/seed/users-bulk.d.ts.map +1 -0
- package/dist/seed/users-bulk.js +224 -0
- package/dist/seed/users-bulk.js.map +1 -0
- package/dist/seed/users.d.ts +3 -0
- package/dist/seed/users.d.ts.map +1 -0
- package/dist/seed/users.js +45 -0
- package/dist/seed/users.js.map +1 -0
- package/dist/seed/verifications.d.ts +5 -0
- package/dist/seed/verifications.d.ts.map +1 -0
- package/dist/seed/verifications.js +164 -0
- package/dist/seed/verifications.js.map +1 -0
- package/dist/service-profile-lexicon.d.ts +11 -0
- package/dist/service-profile-lexicon.d.ts.map +1 -0
- package/dist/service-profile-lexicon.js +115 -0
- package/dist/service-profile-lexicon.js.map +1 -0
- package/dist/service-profile-ozone.d.ts +18 -0
- package/dist/service-profile-ozone.d.ts.map +1 -0
- package/dist/service-profile-ozone.js +333 -0
- package/dist/service-profile-ozone.js.map +1 -0
- package/dist/service-profile.d.ts +24 -0
- package/dist/service-profile.d.ts.map +1 -0
- package/dist/service-profile.js +61 -0
- package/dist/service-profile.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +14 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +86 -0
- package/dist/util.js.map +1 -0
- package/package.json +69 -0
- package/src/bin-multi-pds.ts +166 -0
- package/src/bin.ts +64 -0
- package/src/bsky.ts +198 -0
- package/src/bsync.ts +66 -0
- package/src/const.ts +3 -0
- package/src/env.ts +9 -0
- package/src/feed-gen.ts +96 -0
- package/src/index.ts +17 -0
- package/src/introspect.ts +91 -0
- package/src/mock/data.ts +46 -0
- package/src/mock/img/blur-hash-avatar-b64.ts +1 -0
- package/src/mock/img/labeled-img-b64.ts +1 -0
- package/src/mock/index.ts +702 -0
- package/src/moderator-client.ts +267 -0
- package/src/network-no-appview.ts +89 -0
- package/src/network.ts +243 -0
- package/src/ozone.ts +287 -0
- package/src/pds.ts +118 -0
- package/src/plc.ts +33 -0
- package/src/seed/author-feed.ts +98 -0
- package/src/seed/basic.ts +189 -0
- package/src/seed/client.ts +676 -0
- package/src/seed/follows.ts +57 -0
- package/src/seed/index.ts +11 -0
- package/src/seed/likes.ts +43 -0
- package/src/seed/quotes.ts +53 -0
- package/src/seed/reposts.ts +18 -0
- package/src/seed/thread-v2.ts +925 -0
- package/src/seed/users-bulk.ts +229 -0
- package/src/seed/users.ts +64 -0
- package/src/seed/verifications.ts +254 -0
- package/src/service-profile-lexicon.ts +127 -0
- package/src/service-profile-ozone.ts +375 -0
- package/src/service-profile.ts +95 -0
- package/src/types.ts +68 -0
- package/src/util.ts +118 -0
- package/tsconfig.build.json +25 -0
- package/tsconfig.json +4 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { EXAMPLE_LABELER } from '../const.js';
|
|
2
|
+
import { TestNetwork } from '../network.js';
|
|
3
|
+
import usersSeed from './users.js';
|
|
4
|
+
export default async function basicSeed(sc, users = true) {
|
|
5
|
+
if (users)
|
|
6
|
+
await usersSeed(sc);
|
|
7
|
+
const alice = sc.dids.alice;
|
|
8
|
+
const bob = sc.dids.bob;
|
|
9
|
+
const carol = sc.dids.carol;
|
|
10
|
+
const dan = sc.dids.dan;
|
|
11
|
+
const createdAtMicroseconds = () => ({
|
|
12
|
+
createdAt: new Date().toISOString().replace('Z', '000Z'), // microseconds
|
|
13
|
+
});
|
|
14
|
+
const createdAtTimezone = () => ({
|
|
15
|
+
createdAt: new Date().toISOString().replace('Z', '+00:00'), // iso timezone format
|
|
16
|
+
});
|
|
17
|
+
await sc.follow(alice, bob);
|
|
18
|
+
await sc.follow(alice, carol);
|
|
19
|
+
await sc.follow(alice, dan);
|
|
20
|
+
await sc.follow(carol, alice);
|
|
21
|
+
await sc.follow(bob, alice);
|
|
22
|
+
await sc.follow(bob, carol, createdAtMicroseconds());
|
|
23
|
+
await sc.follow(dan, bob, createdAtTimezone());
|
|
24
|
+
await sc.post(alice, posts.alice[0], undefined, undefined, undefined, {
|
|
25
|
+
labels: {
|
|
26
|
+
$type: 'com.atproto.label.defs#selfLabels',
|
|
27
|
+
values: [{ val: 'self-label' }],
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
await sc.post(bob, posts.bob[0], undefined, undefined, undefined, {
|
|
31
|
+
langs: ['en-US', 'i-klingon'],
|
|
32
|
+
});
|
|
33
|
+
const img1 = await sc.uploadFile(carol, '../dev-env/assets/key-landscape-small.jpg', 'image/jpeg');
|
|
34
|
+
const img2 = await sc.uploadFile(carol, '../dev-env/assets/key-alt.jpg', 'image/jpeg');
|
|
35
|
+
await sc.post(carol, posts.carol[0], undefined, [img1, img2], // Contains both images and a quote
|
|
36
|
+
sc.posts[bob][0].ref);
|
|
37
|
+
await sc.post(dan, posts.dan[0]);
|
|
38
|
+
await sc.post(dan, posts.dan[1], [
|
|
39
|
+
{
|
|
40
|
+
index: { byteStart: 0, byteEnd: 18 },
|
|
41
|
+
features: [
|
|
42
|
+
{
|
|
43
|
+
$type: `app.bsky.richtext.facet#mention`,
|
|
44
|
+
did: alice,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
], undefined, sc.posts[carol][0].ref);
|
|
49
|
+
await sc.post(alice, posts.alice[1], undefined, undefined, undefined, createdAtMicroseconds());
|
|
50
|
+
await sc.post(bob, posts.bob[1], undefined, undefined, undefined, createdAtTimezone());
|
|
51
|
+
await sc.post(alice, posts.alice[2], undefined, undefined, sc.posts[dan][1].ref);
|
|
52
|
+
await sc.like(bob, sc.posts[alice][1].ref);
|
|
53
|
+
await sc.like(bob, sc.posts[alice][2].ref);
|
|
54
|
+
await sc.like(carol, sc.posts[alice][1].ref);
|
|
55
|
+
await sc.like(carol, sc.posts[alice][2].ref);
|
|
56
|
+
await sc.like(dan, sc.posts[alice][1].ref);
|
|
57
|
+
await sc.like(alice, sc.posts[carol][0].ref, createdAtMicroseconds());
|
|
58
|
+
await sc.like(bob, sc.posts[carol][0].ref, createdAtTimezone());
|
|
59
|
+
const replyImg = await sc.uploadFile(bob, '../dev-env/assets/key-landscape-small.jpg', 'image/jpeg');
|
|
60
|
+
// must ensure ordering of replies in indexing
|
|
61
|
+
await sc.network.processAll();
|
|
62
|
+
await sc.reply(bob, sc.posts[alice][1].ref, sc.posts[alice][1].ref, replies.bob[0], undefined, [replyImg]);
|
|
63
|
+
await sc.reply(carol, sc.posts[alice][1].ref, sc.posts[alice][1].ref, replies.carol[0]);
|
|
64
|
+
await sc.network.processAll();
|
|
65
|
+
const alicesReplyToBob = await sc.reply(alice, sc.posts[alice][1].ref, sc.replies[bob][0].ref, replies.alice[0]);
|
|
66
|
+
await sc.repost(carol, sc.posts[dan][1].ref);
|
|
67
|
+
await sc.repost(dan, sc.posts[alice][1].ref);
|
|
68
|
+
await sc.repost(dan, alicesReplyToBob.ref);
|
|
69
|
+
if (sc.network instanceof TestNetwork) {
|
|
70
|
+
const bsky = sc.network.bsky;
|
|
71
|
+
await createLabel(bsky, {
|
|
72
|
+
val: 'test-label',
|
|
73
|
+
uri: sc.posts[alice][2].ref.uriStr,
|
|
74
|
+
cid: sc.posts[alice][2].ref.cidStr,
|
|
75
|
+
});
|
|
76
|
+
await createLabel(bsky, {
|
|
77
|
+
val: 'test-label',
|
|
78
|
+
uri: sc.replies[bob][0].ref.uriStr,
|
|
79
|
+
cid: sc.replies[bob][0].ref.cidStr,
|
|
80
|
+
});
|
|
81
|
+
await createLabel(bsky, {
|
|
82
|
+
val: 'test-label-2',
|
|
83
|
+
uri: sc.replies[bob][0].ref.uriStr,
|
|
84
|
+
cid: sc.replies[bob][0].ref.cidStr,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return sc;
|
|
88
|
+
}
|
|
89
|
+
export const posts = {
|
|
90
|
+
alice: ['hey there', 'again', 'yoohoo label_me'],
|
|
91
|
+
bob: ['bob back at it again!', 'bobby boy here', 'yoohoo'],
|
|
92
|
+
carol: ['hi im carol'],
|
|
93
|
+
dan: ['dan here!', '@alice.bluesky.xyz is the best'],
|
|
94
|
+
};
|
|
95
|
+
export const replies = {
|
|
96
|
+
alice: ['thanks bob'],
|
|
97
|
+
bob: ['hear that label_me label_me_2'],
|
|
98
|
+
carol: ['of course'],
|
|
99
|
+
};
|
|
100
|
+
const createLabel = async (bsky, opts) => {
|
|
101
|
+
await bsky.db.db
|
|
102
|
+
.insertInto('label')
|
|
103
|
+
.values({
|
|
104
|
+
uri: opts.uri,
|
|
105
|
+
cid: opts.cid,
|
|
106
|
+
val: opts.val,
|
|
107
|
+
cts: new Date().toISOString(),
|
|
108
|
+
neg: false,
|
|
109
|
+
src: EXAMPLE_LABELER, // this did is also configured on labelsFromIssuerDids
|
|
110
|
+
})
|
|
111
|
+
.execute();
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=basic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../src/seed/basic.ts"],"names":[],"mappings":"AACA,OAA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AAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM;YAClC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM;SACnC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC;IAChD,GAAG,EAAE,CAAC,uBAAuB,EAAE,gBAAgB,EAAE,QAAQ,CAAC;IAC1D,KAAK,EAAE,CAAC,aAAa,CAAC;IACtB,GAAG,EAAE,CAAC,WAAW,EAAE,gCAAgC,CAAC;CACrD,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,CAAC,YAAY,CAAC;IACrB,GAAG,EAAE,CAAC,+BAA+B,CAAC;IACtC,KAAK,EAAE,CAAC,WAAW,CAAC;CACrB,CAAA;AAED,MAAM,WAAW,GAAG,KAAK,EACvB,IAAc,EACd,IAA+C,EAC/C,EAAE;IACF,MAAM,IAAI,CAAC,EAAE,CAAC,EAAE;SACb,UAAU,CAAC,OAAO,CAAC;SACnB,MAAM,CAAC;QACN,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC7B,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,eAAe,EAAE,sDAAsD;KAC7E,CAAC;SACD,OAAO,EAAE,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { TestBsky } from '../bsky.js'\nimport { EXAMPLE_LABELER } from '../const.js'\nimport type { TestNetworkNoAppView } from '../network-no-appview.js'\nimport { TestNetwork } from '../network.js'\nimport type { SeedClient } from './client.js'\nimport usersSeed from './users.js'\n\nexport default async function basicSeed(\n sc: SeedClient<TestNetwork | TestNetworkNoAppView>,\n users = true,\n) {\n if (users) await usersSeed(sc)\n\n const alice = sc.dids.alice\n const bob = sc.dids.bob\n const carol = sc.dids.carol\n const dan = sc.dids.dan\n const createdAtMicroseconds = () => ({\n createdAt: new Date().toISOString().replace('Z', '000Z'), // microseconds\n })\n const createdAtTimezone = () => ({\n createdAt: new Date().toISOString().replace('Z', '+00:00'), // iso timezone format\n })\n\n await sc.follow(alice, bob)\n await sc.follow(alice, carol)\n await sc.follow(alice, dan)\n await sc.follow(carol, alice)\n await sc.follow(bob, alice)\n await sc.follow(bob, carol, createdAtMicroseconds())\n await sc.follow(dan, bob, createdAtTimezone())\n await sc.post(alice, posts.alice[0], undefined, undefined, undefined, {\n labels: {\n $type: 'com.atproto.label.defs#selfLabels',\n values: [{ val: 'self-label' }],\n },\n })\n await sc.post(bob, posts.bob[0], undefined, undefined, undefined, {\n langs: ['en-US', 'i-klingon'],\n })\n const img1 = await sc.uploadFile(\n carol,\n '../dev-env/assets/key-landscape-small.jpg',\n 'image/jpeg',\n )\n const img2 = await sc.uploadFile(\n carol,\n '../dev-env/assets/key-alt.jpg',\n 'image/jpeg',\n )\n await sc.post(\n carol,\n posts.carol[0],\n undefined,\n [img1, img2], // Contains both images and a quote\n sc.posts[bob][0].ref,\n )\n await sc.post(dan, posts.dan[0])\n await sc.post(\n dan,\n posts.dan[1],\n [\n {\n index: { byteStart: 0, byteEnd: 18 },\n features: [\n {\n $type: `app.bsky.richtext.facet#mention`,\n did: alice,\n },\n ],\n },\n ],\n undefined,\n sc.posts[carol][0].ref, // This post contains an images embed\n )\n await sc.post(\n alice,\n posts.alice[1],\n undefined,\n undefined,\n undefined,\n createdAtMicroseconds(),\n )\n await sc.post(\n bob,\n posts.bob[1],\n undefined,\n undefined,\n undefined,\n createdAtTimezone(),\n )\n await sc.post(\n alice,\n posts.alice[2],\n undefined,\n undefined,\n sc.posts[dan][1].ref, // This post contains a record embed which contains an images embed\n )\n await sc.like(bob, sc.posts[alice][1].ref)\n await sc.like(bob, sc.posts[alice][2].ref)\n await sc.like(carol, sc.posts[alice][1].ref)\n await sc.like(carol, sc.posts[alice][2].ref)\n await sc.like(dan, sc.posts[alice][1].ref)\n await sc.like(alice, sc.posts[carol][0].ref, createdAtMicroseconds())\n await sc.like(bob, sc.posts[carol][0].ref, createdAtTimezone())\n\n const replyImg = await sc.uploadFile(\n bob,\n '../dev-env/assets/key-landscape-small.jpg',\n 'image/jpeg',\n )\n // must ensure ordering of replies in indexing\n await sc.network.processAll()\n await sc.reply(\n bob,\n sc.posts[alice][1].ref,\n sc.posts[alice][1].ref,\n replies.bob[0],\n undefined,\n [replyImg],\n )\n await sc.reply(\n carol,\n sc.posts[alice][1].ref,\n sc.posts[alice][1].ref,\n replies.carol[0],\n )\n await sc.network.processAll()\n const alicesReplyToBob = await sc.reply(\n alice,\n sc.posts[alice][1].ref,\n sc.replies[bob][0].ref,\n replies.alice[0],\n )\n await sc.repost(carol, sc.posts[dan][1].ref)\n await sc.repost(dan, sc.posts[alice][1].ref)\n await sc.repost(dan, alicesReplyToBob.ref)\n\n if (sc.network instanceof TestNetwork) {\n const bsky = sc.network.bsky\n await createLabel(bsky, {\n val: 'test-label',\n uri: sc.posts[alice][2].ref.uriStr,\n cid: sc.posts[alice][2].ref.cidStr,\n })\n await createLabel(bsky, {\n val: 'test-label',\n uri: sc.replies[bob][0].ref.uriStr,\n cid: sc.replies[bob][0].ref.cidStr,\n })\n await createLabel(bsky, {\n val: 'test-label-2',\n uri: sc.replies[bob][0].ref.uriStr,\n cid: sc.replies[bob][0].ref.cidStr,\n })\n }\n\n return sc\n}\n\nexport const posts = {\n alice: ['hey there', 'again', 'yoohoo label_me'],\n bob: ['bob back at it again!', 'bobby boy here', 'yoohoo'],\n carol: ['hi im carol'],\n dan: ['dan here!', '@alice.bluesky.xyz is the best'],\n}\n\nexport const replies = {\n alice: ['thanks bob'],\n bob: ['hear that label_me label_me_2'],\n carol: ['of course'],\n}\n\nconst createLabel = async (\n bsky: TestBsky,\n opts: { uri: string; cid: string; val: string },\n) => {\n await bsky.db.db\n .insertInto('label')\n .values({\n uri: opts.uri,\n cid: opts.cid,\n val: opts.val,\n cts: new Date().toISOString(),\n neg: false,\n src: EXAMPLE_LABELER, // this did is also configured on labelsFromIssuerDids\n })\n .execute()\n}\n"]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import type { $Typed, AppBskyActorProfile, AppBskyFeedLike, AppBskyFeedPost, AppBskyFeedRepost, AppBskyGraphBlock, AppBskyGraphFollow, AppBskyGraphList, AppBskyGraphVerification, AppBskyRichtextFacet, AtpAgent, ChatBskyConvoDefs, ComAtprotoAdminDefs, ComAtprotoModerationCreateReport, ComAtprotoRepoStrongRef } from '@atproto/api';
|
|
3
|
+
import type { CidString, Client } from '@atproto/lex';
|
|
4
|
+
import type { BlobRef } from '@atproto/lexicon';
|
|
5
|
+
import { AtUri, type AtUriString, type DidString, type HandleString } from '@atproto/syntax';
|
|
6
|
+
import type { TestNetworkNoAppView } from '../network-no-appview.js';
|
|
7
|
+
export type ImageRef = {
|
|
8
|
+
image: BlobRef;
|
|
9
|
+
alt: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class RecordRef {
|
|
12
|
+
uri: AtUri;
|
|
13
|
+
cid: CID;
|
|
14
|
+
constructor(uri: AtUri | string, cid: CID | string);
|
|
15
|
+
get raw(): {
|
|
16
|
+
uri: AtUriString;
|
|
17
|
+
cid: CidString;
|
|
18
|
+
};
|
|
19
|
+
get uriStr(): AtUriString;
|
|
20
|
+
get cidStr(): CidString;
|
|
21
|
+
}
|
|
22
|
+
export type Account = {
|
|
23
|
+
did: DidString;
|
|
24
|
+
accessJwt: string;
|
|
25
|
+
refreshJwt: string;
|
|
26
|
+
handle: HandleString;
|
|
27
|
+
email: string;
|
|
28
|
+
password: string;
|
|
29
|
+
};
|
|
30
|
+
export declare class SeedClient<Network extends TestNetworkNoAppView = TestNetworkNoAppView> {
|
|
31
|
+
network: Network;
|
|
32
|
+
agent: AtpAgent;
|
|
33
|
+
client: Client;
|
|
34
|
+
accounts: Record<DidString, Account>;
|
|
35
|
+
profiles: Record<DidString, {
|
|
36
|
+
displayName: string;
|
|
37
|
+
description: string;
|
|
38
|
+
avatar: {
|
|
39
|
+
cid: string;
|
|
40
|
+
mimeType: string;
|
|
41
|
+
};
|
|
42
|
+
joinedViaStarterPack: RecordRef | undefined;
|
|
43
|
+
ref: RecordRef;
|
|
44
|
+
}>;
|
|
45
|
+
follows: Record<DidString, Record<DidString, RecordRef>>;
|
|
46
|
+
blocks: Record<DidString, Record<DidString, RecordRef>>;
|
|
47
|
+
mutes: Record<DidString, Set<DidString>>;
|
|
48
|
+
posts: Record<DidString, {
|
|
49
|
+
text: string;
|
|
50
|
+
ref: RecordRef;
|
|
51
|
+
images: ImageRef[];
|
|
52
|
+
quote?: RecordRef;
|
|
53
|
+
}[]>;
|
|
54
|
+
likes: Record<DidString, Record<string, AtUri>>;
|
|
55
|
+
replies: Record<string, {
|
|
56
|
+
text: string;
|
|
57
|
+
ref: RecordRef;
|
|
58
|
+
images: ImageRef[];
|
|
59
|
+
}[]>;
|
|
60
|
+
reposts: Record<DidString, RecordRef[]>;
|
|
61
|
+
lists: Record<DidString, Record<AtUriString, {
|
|
62
|
+
ref: RecordRef;
|
|
63
|
+
items: Record<DidString, RecordRef>;
|
|
64
|
+
}>>;
|
|
65
|
+
feedgens: Record<DidString, Record<AtUriString, {
|
|
66
|
+
ref: RecordRef;
|
|
67
|
+
items: Record<string, RecordRef>;
|
|
68
|
+
}>>;
|
|
69
|
+
starterpacks: Record<DidString, Record<AtUriString, {
|
|
70
|
+
ref: RecordRef;
|
|
71
|
+
name: string;
|
|
72
|
+
list: RecordRef;
|
|
73
|
+
feeds: readonly AtUriString[];
|
|
74
|
+
}>>;
|
|
75
|
+
verifications: Record<DidString, Record<DidString, AtUri>>;
|
|
76
|
+
dids: Record<string, DidString>;
|
|
77
|
+
constructor(network: Network, agent: AtpAgent, client: Client);
|
|
78
|
+
createAccount(shortName: string, params: {
|
|
79
|
+
handle: HandleString;
|
|
80
|
+
email: string;
|
|
81
|
+
password: string;
|
|
82
|
+
inviteCode?: string;
|
|
83
|
+
}): Promise<Account>;
|
|
84
|
+
updateHandle(by: DidString, handle: HandleString): Promise<void>;
|
|
85
|
+
createProfile(by: DidString, displayName: string, description: string, selfLabels?: readonly string[], joinedViaStarterPack?: RecordRef, overrides?: Partial<AppBskyActorProfile.Record>): Promise<{
|
|
86
|
+
displayName: string;
|
|
87
|
+
description: string;
|
|
88
|
+
avatar: {
|
|
89
|
+
cid: string;
|
|
90
|
+
mimeType: string;
|
|
91
|
+
};
|
|
92
|
+
ref: RecordRef;
|
|
93
|
+
joinedViaStarterPack?: RecordRef;
|
|
94
|
+
}>;
|
|
95
|
+
updateProfile(by: DidString, record: Record<string, unknown>): Promise<{
|
|
96
|
+
displayName: string;
|
|
97
|
+
description: string;
|
|
98
|
+
avatar: {
|
|
99
|
+
cid: string;
|
|
100
|
+
mimeType: string;
|
|
101
|
+
};
|
|
102
|
+
joinedViaStarterPack: RecordRef | undefined;
|
|
103
|
+
ref: RecordRef;
|
|
104
|
+
}>;
|
|
105
|
+
follow(from: DidString, to: DidString, overrides?: Partial<AppBskyGraphFollow.Record>): Promise<RecordRef>;
|
|
106
|
+
unfollow(from: DidString, to: DidString): Promise<void>;
|
|
107
|
+
block(from: DidString, to: DidString, overrides?: Partial<AppBskyGraphBlock.Record>): Promise<RecordRef>;
|
|
108
|
+
unblock(from: DidString, to: DidString): Promise<void>;
|
|
109
|
+
mute(from: DidString, to: DidString): Promise<any>;
|
|
110
|
+
post(by: DidString, text: string, facets?: AppBskyRichtextFacet.Main[], images?: ImageRef[], quote?: RecordRef, overrides?: Partial<AppBskyFeedPost.Record>): Promise<{
|
|
111
|
+
text: string;
|
|
112
|
+
ref: RecordRef;
|
|
113
|
+
images: ImageRef[];
|
|
114
|
+
quote: RecordRef | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
deletePost(by: DidString, uri: AtUri): Promise<void>;
|
|
117
|
+
uploadFile(by: DidString, filePath: string, encoding: string): Promise<ImageRef>;
|
|
118
|
+
like(by: DidString, subject: RecordRef, overrides?: Partial<AppBskyFeedLike.Record>): Promise<AtUri>;
|
|
119
|
+
reply(by: DidString, root: RecordRef, parent: RecordRef, text: string, facets?: AppBskyRichtextFacet.Main[], images?: ImageRef[], overrides?: Partial<AppBskyFeedPost.Record>): Promise<{
|
|
120
|
+
text: string;
|
|
121
|
+
ref: RecordRef;
|
|
122
|
+
images: ImageRef[];
|
|
123
|
+
}>;
|
|
124
|
+
repost(by: DidString, subject: RecordRef, overrides?: Partial<AppBskyFeedRepost.Record>): Promise<RecordRef>;
|
|
125
|
+
createList(by: DidString, name: string, purpose: 'mod' | 'curate' | 'reference', overrides?: Partial<AppBskyGraphList.Record>): Promise<RecordRef>;
|
|
126
|
+
createFeedGen(by: DidString, feedDid: string, name: string): Promise<RecordRef>;
|
|
127
|
+
createStarterPack(by: DidString, name: string, actors: readonly DidString[], feeds?: readonly AtUriString[]): Promise<RecordRef>;
|
|
128
|
+
addToList(by: DidString, subject: DidString, list: RecordRef): Promise<RecordRef>;
|
|
129
|
+
rmFromList(by: DidString, subject: DidString, list: RecordRef): Promise<void>;
|
|
130
|
+
createReport(opts: {
|
|
131
|
+
reasonType: ComAtprotoModerationCreateReport.InputSchema['reasonType'];
|
|
132
|
+
subject: $Typed<ComAtprotoAdminDefs.RepoRef> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<ChatBskyConvoDefs.MessageRef> | $Typed<ChatBskyConvoDefs.ConvoRef> | {
|
|
133
|
+
$type: string;
|
|
134
|
+
};
|
|
135
|
+
reason?: string;
|
|
136
|
+
reportedBy: DidString;
|
|
137
|
+
}): Promise<ComAtprotoModerationCreateReport.OutputSchema & {
|
|
138
|
+
subject: $Typed<ComAtprotoAdminDefs.RepoRef> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<ChatBskyConvoDefs.MessageRef> | $Typed<ChatBskyConvoDefs.ConvoRef> | {
|
|
139
|
+
$type: string;
|
|
140
|
+
};
|
|
141
|
+
}>;
|
|
142
|
+
verify(by: DidString, subject: DidString, handle: HandleString, displayName: string, overrides?: Partial<AppBskyGraphVerification.Record>): Promise<AtUri>;
|
|
143
|
+
unverify(by: DidString, subject: DidString): Promise<void>;
|
|
144
|
+
getHeaders(did: DidString): {
|
|
145
|
+
authorization: string;
|
|
146
|
+
};
|
|
147
|
+
static getHeaders(jwt: string): {
|
|
148
|
+
authorization: string;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/seed/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,gCAAgC,EAChC,uBAAuB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EACL,KAAK,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAepE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,OAAO,CAAA;IAC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,OAAO,CAAC,GACnC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,GACpC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,GACpC,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAClC;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KACtB,CACF,CAUA;IAEK,MAAM,CACV,EAAE,EAAE,SAAS,EACb,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,MAAM,CAAC,kBAgBrD;IAEK,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,iBAW/C;IAED,UAAU,CAAC,GAAG,EAAE,SAAS;;MAExB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM;QAClB,aAAa;MACvB;CACF"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { CID } from 'multiformats/cid';
|
|
5
|
+
import { AtUri, } from '@atproto/syntax';
|
|
6
|
+
// Makes it simple to create data via the XRPC client,
|
|
7
|
+
// and keeps track of all created data in memory for convenience.
|
|
8
|
+
let AVATAR_IMG;
|
|
9
|
+
// AVATAR_PATH is defined in a non-CWD-dependant way, so this works
|
|
10
|
+
// for any consumer of this package, even outside the atproto repo.
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const AVATAR_PATH = path.resolve(__dirname, '../../assets/key-portrait-small.jpg');
|
|
13
|
+
export class RecordRef {
|
|
14
|
+
constructor(uri, cid) {
|
|
15
|
+
this.uri = new AtUri(uri.toString());
|
|
16
|
+
this.cid = CID.parse(cid.toString());
|
|
17
|
+
}
|
|
18
|
+
get raw() {
|
|
19
|
+
return {
|
|
20
|
+
uri: this.uri.toString(),
|
|
21
|
+
cid: this.cid.toString(),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
get uriStr() {
|
|
25
|
+
return this.uri.toString();
|
|
26
|
+
}
|
|
27
|
+
get cidStr() {
|
|
28
|
+
return this.cid.toString();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class SeedClient {
|
|
32
|
+
constructor(network, agent, client) {
|
|
33
|
+
this.network = network;
|
|
34
|
+
this.agent = agent;
|
|
35
|
+
this.client = client;
|
|
36
|
+
this.accounts = {};
|
|
37
|
+
this.profiles = {};
|
|
38
|
+
this.follows = {};
|
|
39
|
+
this.blocks = {};
|
|
40
|
+
this.mutes = {};
|
|
41
|
+
this.posts = {};
|
|
42
|
+
this.likes = {};
|
|
43
|
+
this.replies = {};
|
|
44
|
+
this.reposts = {};
|
|
45
|
+
this.lists = {};
|
|
46
|
+
this.feedgens = {};
|
|
47
|
+
this.starterpacks = {};
|
|
48
|
+
this.verifications = {};
|
|
49
|
+
this.dids = {};
|
|
50
|
+
}
|
|
51
|
+
async createAccount(shortName, params) {
|
|
52
|
+
const { data: account } = await this.agent.com.atproto.server.createAccount(params);
|
|
53
|
+
const did = account.did;
|
|
54
|
+
this.dids[shortName] = did;
|
|
55
|
+
this.accounts[account.did] = {
|
|
56
|
+
// @NOTE type case needed until we move test to lex-sdk
|
|
57
|
+
...account,
|
|
58
|
+
did,
|
|
59
|
+
email: params.email,
|
|
60
|
+
password: params.password,
|
|
61
|
+
};
|
|
62
|
+
return this.accounts[account.did];
|
|
63
|
+
}
|
|
64
|
+
async updateHandle(by, handle) {
|
|
65
|
+
await this.agent.com.atproto.identity.updateHandle({ handle }, { encoding: 'application/json', headers: this.getHeaders(by) });
|
|
66
|
+
}
|
|
67
|
+
async createProfile(by, displayName, description, selfLabels, joinedViaStarterPack, overrides) {
|
|
68
|
+
AVATAR_IMG ??= await fs.readFile(AVATAR_PATH);
|
|
69
|
+
let avatarBlob;
|
|
70
|
+
{
|
|
71
|
+
const res = await this.agent.com.atproto.repo.uploadBlob(AVATAR_IMG, {
|
|
72
|
+
encoding: 'image/jpeg',
|
|
73
|
+
headers: this.getHeaders(by),
|
|
74
|
+
});
|
|
75
|
+
avatarBlob = res.data.blob;
|
|
76
|
+
}
|
|
77
|
+
{
|
|
78
|
+
const res = await this.agent.app.bsky.actor.profile.create({ repo: by }, {
|
|
79
|
+
displayName,
|
|
80
|
+
description,
|
|
81
|
+
avatar: avatarBlob,
|
|
82
|
+
labels: selfLabels
|
|
83
|
+
? {
|
|
84
|
+
$type: 'com.atproto.label.defs#selfLabels',
|
|
85
|
+
values: selfLabels.map((val) => ({ val })),
|
|
86
|
+
}
|
|
87
|
+
: undefined,
|
|
88
|
+
joinedViaStarterPack: joinedViaStarterPack?.raw,
|
|
89
|
+
createdAt: new Date().toISOString(),
|
|
90
|
+
...overrides,
|
|
91
|
+
}, this.getHeaders(by));
|
|
92
|
+
this.profiles[by] = {
|
|
93
|
+
displayName,
|
|
94
|
+
description,
|
|
95
|
+
avatar: avatarBlob,
|
|
96
|
+
joinedViaStarterPack,
|
|
97
|
+
ref: new RecordRef(res.uri, res.cid),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return this.profiles[by];
|
|
101
|
+
}
|
|
102
|
+
async updateProfile(by, record) {
|
|
103
|
+
const res = await this.agent.com.atproto.repo.putRecord({
|
|
104
|
+
repo: by,
|
|
105
|
+
collection: 'app.bsky.actor.profile',
|
|
106
|
+
rkey: 'self',
|
|
107
|
+
record,
|
|
108
|
+
}, { headers: this.getHeaders(by), encoding: 'application/json' });
|
|
109
|
+
this.profiles[by] = {
|
|
110
|
+
...(this.profiles[by] ?? {}),
|
|
111
|
+
...record,
|
|
112
|
+
ref: new RecordRef(res.data.uri, res.data.cid),
|
|
113
|
+
};
|
|
114
|
+
return this.profiles[by];
|
|
115
|
+
}
|
|
116
|
+
async follow(from, to, overrides) {
|
|
117
|
+
const res = await this.agent.app.bsky.graph.follow.create({ repo: from }, {
|
|
118
|
+
subject: to,
|
|
119
|
+
createdAt: new Date().toISOString(),
|
|
120
|
+
...overrides,
|
|
121
|
+
}, this.getHeaders(from));
|
|
122
|
+
this.follows[from] ??= {};
|
|
123
|
+
this.follows[from][to] = new RecordRef(res.uri, res.cid);
|
|
124
|
+
return this.follows[from][to];
|
|
125
|
+
}
|
|
126
|
+
async unfollow(from, to) {
|
|
127
|
+
const follow = this.follows[from][to];
|
|
128
|
+
if (!follow) {
|
|
129
|
+
throw new Error('follow does not exist');
|
|
130
|
+
}
|
|
131
|
+
await this.agent.app.bsky.graph.follow.delete({ repo: from, rkey: follow.uri.rkey }, this.getHeaders(from));
|
|
132
|
+
delete this.follows[from][to];
|
|
133
|
+
}
|
|
134
|
+
async block(from, to, overrides) {
|
|
135
|
+
const res = await this.agent.app.bsky.graph.block.create({ repo: from }, {
|
|
136
|
+
subject: to,
|
|
137
|
+
createdAt: new Date().toISOString(),
|
|
138
|
+
...overrides,
|
|
139
|
+
}, this.getHeaders(from));
|
|
140
|
+
this.blocks[from] ??= {};
|
|
141
|
+
this.blocks[from][to] = new RecordRef(res.uri, res.cid);
|
|
142
|
+
return this.blocks[from][to];
|
|
143
|
+
}
|
|
144
|
+
async unblock(from, to) {
|
|
145
|
+
const block = this.blocks[from][to];
|
|
146
|
+
if (!block) {
|
|
147
|
+
throw new Error('block does not exist');
|
|
148
|
+
}
|
|
149
|
+
await this.agent.app.bsky.graph.block.delete({ repo: from, rkey: block.uri.rkey }, this.getHeaders(from));
|
|
150
|
+
delete this.blocks[from][to];
|
|
151
|
+
}
|
|
152
|
+
async mute(from, to) {
|
|
153
|
+
await this.agent.app.bsky.graph.muteActor({
|
|
154
|
+
actor: to,
|
|
155
|
+
}, { headers: this.getHeaders(from) });
|
|
156
|
+
this.mutes[from] ??= new Set();
|
|
157
|
+
this.mutes[from].add(to);
|
|
158
|
+
return this.mutes[from][to];
|
|
159
|
+
}
|
|
160
|
+
async post(by, text, facets, images, quote, overrides) {
|
|
161
|
+
const imageEmbed = images && {
|
|
162
|
+
$type: 'app.bsky.embed.images',
|
|
163
|
+
images,
|
|
164
|
+
};
|
|
165
|
+
const recordEmbed = quote && {
|
|
166
|
+
record: { uri: quote.uriStr, cid: quote.cidStr },
|
|
167
|
+
};
|
|
168
|
+
const embed = imageEmbed && recordEmbed
|
|
169
|
+
? {
|
|
170
|
+
$type: 'app.bsky.embed.recordWithMedia',
|
|
171
|
+
record: recordEmbed,
|
|
172
|
+
media: imageEmbed,
|
|
173
|
+
}
|
|
174
|
+
: recordEmbed
|
|
175
|
+
? { $type: 'app.bsky.embed.record', ...recordEmbed }
|
|
176
|
+
: imageEmbed;
|
|
177
|
+
const res = await this.agent.app.bsky.feed.post.create({ repo: by }, {
|
|
178
|
+
text: text,
|
|
179
|
+
facets,
|
|
180
|
+
embed,
|
|
181
|
+
createdAt: new Date().toISOString(),
|
|
182
|
+
...overrides,
|
|
183
|
+
}, this.getHeaders(by));
|
|
184
|
+
this.posts[by] ??= [];
|
|
185
|
+
const post = {
|
|
186
|
+
text,
|
|
187
|
+
ref: new RecordRef(res.uri, res.cid),
|
|
188
|
+
images: images ?? [],
|
|
189
|
+
quote,
|
|
190
|
+
};
|
|
191
|
+
this.posts[by].push(post);
|
|
192
|
+
return post;
|
|
193
|
+
}
|
|
194
|
+
async deletePost(by, uri) {
|
|
195
|
+
await this.agent.app.bsky.feed.post.delete({
|
|
196
|
+
repo: by,
|
|
197
|
+
rkey: uri.rkey,
|
|
198
|
+
}, this.getHeaders(by));
|
|
199
|
+
}
|
|
200
|
+
async uploadFile(by, filePath, encoding) {
|
|
201
|
+
const file = await fs.readFile(filePath);
|
|
202
|
+
const res = await this.agent.com.atproto.repo.uploadBlob(file, {
|
|
203
|
+
headers: this.getHeaders(by),
|
|
204
|
+
encoding,
|
|
205
|
+
});
|
|
206
|
+
return { image: res.data.blob, alt: filePath };
|
|
207
|
+
}
|
|
208
|
+
async like(by, subject, overrides) {
|
|
209
|
+
const res = await this.agent.app.bsky.feed.like.create({ repo: by }, {
|
|
210
|
+
subject: subject.raw,
|
|
211
|
+
createdAt: new Date().toISOString(),
|
|
212
|
+
...overrides,
|
|
213
|
+
}, this.getHeaders(by));
|
|
214
|
+
this.likes[by] ??= {};
|
|
215
|
+
this.likes[by][subject.uriStr] = new AtUri(res.uri);
|
|
216
|
+
return this.likes[by][subject.uriStr];
|
|
217
|
+
}
|
|
218
|
+
async reply(by, root, parent, text, facets, images, overrides) {
|
|
219
|
+
const embed = images
|
|
220
|
+
? {
|
|
221
|
+
$type: 'app.bsky.embed.images',
|
|
222
|
+
images,
|
|
223
|
+
}
|
|
224
|
+
: undefined;
|
|
225
|
+
const res = await this.agent.app.bsky.feed.post.create({ repo: by }, {
|
|
226
|
+
text: text,
|
|
227
|
+
reply: {
|
|
228
|
+
root: root.raw,
|
|
229
|
+
parent: parent.raw,
|
|
230
|
+
},
|
|
231
|
+
facets,
|
|
232
|
+
embed,
|
|
233
|
+
createdAt: new Date().toISOString(),
|
|
234
|
+
...overrides,
|
|
235
|
+
}, this.getHeaders(by));
|
|
236
|
+
this.replies[by] ??= [];
|
|
237
|
+
const reply = {
|
|
238
|
+
text,
|
|
239
|
+
ref: new RecordRef(res.uri, res.cid),
|
|
240
|
+
images: images ?? [],
|
|
241
|
+
};
|
|
242
|
+
this.replies[by].push(reply);
|
|
243
|
+
return reply;
|
|
244
|
+
}
|
|
245
|
+
async repost(by, subject, overrides) {
|
|
246
|
+
const res = await this.agent.app.bsky.feed.repost.create({ repo: by }, {
|
|
247
|
+
subject: subject.raw,
|
|
248
|
+
createdAt: new Date().toISOString(),
|
|
249
|
+
...overrides,
|
|
250
|
+
}, this.getHeaders(by));
|
|
251
|
+
this.reposts[by] ??= [];
|
|
252
|
+
const repost = new RecordRef(res.uri, res.cid);
|
|
253
|
+
this.reposts[by].push(repost);
|
|
254
|
+
return repost;
|
|
255
|
+
}
|
|
256
|
+
async createList(by, name, purpose, overrides) {
|
|
257
|
+
const res = await this.agent.app.bsky.graph.list.create({ repo: by }, {
|
|
258
|
+
name,
|
|
259
|
+
purpose: purpose === 'mod'
|
|
260
|
+
? 'app.bsky.graph.defs#modlist'
|
|
261
|
+
: purpose === 'curate'
|
|
262
|
+
? 'app.bsky.graph.defs#curatelist'
|
|
263
|
+
: 'app.bsky.graph.defs#referencelist',
|
|
264
|
+
createdAt: new Date().toISOString(),
|
|
265
|
+
...(overrides || {}),
|
|
266
|
+
}, this.getHeaders(by));
|
|
267
|
+
this.lists[by] ??= {};
|
|
268
|
+
const ref = new RecordRef(res.uri, res.cid);
|
|
269
|
+
this.lists[by][ref.uriStr] = {
|
|
270
|
+
ref: ref,
|
|
271
|
+
items: {},
|
|
272
|
+
};
|
|
273
|
+
return ref;
|
|
274
|
+
}
|
|
275
|
+
async createFeedGen(by, feedDid, name) {
|
|
276
|
+
const res = await this.agent.app.bsky.feed.generator.create({ repo: by }, {
|
|
277
|
+
did: feedDid,
|
|
278
|
+
displayName: name,
|
|
279
|
+
createdAt: new Date().toISOString(),
|
|
280
|
+
}, this.getHeaders(by));
|
|
281
|
+
this.feedgens[by] ??= {};
|
|
282
|
+
const ref = new RecordRef(res.uri, res.cid);
|
|
283
|
+
this.feedgens[by][ref.uriStr] = {
|
|
284
|
+
ref: ref,
|
|
285
|
+
items: {},
|
|
286
|
+
};
|
|
287
|
+
return ref;
|
|
288
|
+
}
|
|
289
|
+
async createStarterPack(by, name, actors, feeds) {
|
|
290
|
+
const list = await this.createList(by, 'n/a', 'reference');
|
|
291
|
+
for (const did of actors) {
|
|
292
|
+
await this.addToList(by, did, list);
|
|
293
|
+
}
|
|
294
|
+
const res = await this.agent.app.bsky.graph.starterpack.create({ repo: by }, {
|
|
295
|
+
name,
|
|
296
|
+
list: list.uriStr,
|
|
297
|
+
feeds: feeds?.map((uri) => ({ uri })),
|
|
298
|
+
createdAt: new Date().toISOString(),
|
|
299
|
+
}, this.getHeaders(by));
|
|
300
|
+
this.starterpacks[by] ??= {};
|
|
301
|
+
const ref = new RecordRef(res.uri, res.cid);
|
|
302
|
+
this.starterpacks[by][ref.uriStr] = {
|
|
303
|
+
ref: ref,
|
|
304
|
+
list,
|
|
305
|
+
feeds: feeds ?? [],
|
|
306
|
+
name,
|
|
307
|
+
};
|
|
308
|
+
return ref;
|
|
309
|
+
}
|
|
310
|
+
async addToList(by, subject, list) {
|
|
311
|
+
const res = await this.agent.app.bsky.graph.listitem.create({ repo: by }, { subject, list: list.uriStr, createdAt: new Date().toISOString() }, this.getHeaders(by));
|
|
312
|
+
const ref = new RecordRef(res.uri, res.cid);
|
|
313
|
+
const found = (this.lists[by] ?? {})[list.uriStr];
|
|
314
|
+
if (found) {
|
|
315
|
+
found.items[subject] = ref;
|
|
316
|
+
}
|
|
317
|
+
return ref;
|
|
318
|
+
}
|
|
319
|
+
async rmFromList(by, subject, list) {
|
|
320
|
+
const foundList = (this.lists[by] ?? {})[list.uriStr] ?? {};
|
|
321
|
+
if (!foundList)
|
|
322
|
+
return;
|
|
323
|
+
const foundItem = foundList.items[subject];
|
|
324
|
+
if (!foundItem)
|
|
325
|
+
return;
|
|
326
|
+
await this.agent.app.bsky.graph.listitem.delete({ repo: by, rkey: foundItem.uri.rkey }, this.getHeaders(by));
|
|
327
|
+
delete foundList.items[subject];
|
|
328
|
+
}
|
|
329
|
+
// override public signature to add support for convos and messages
|
|
330
|
+
async createReport(opts) {
|
|
331
|
+
const { reasonType, subject, reason, reportedBy } = opts;
|
|
332
|
+
const result = await this.agent.com.atproto.moderation.createReport({ reasonType, subject, reason }, {
|
|
333
|
+
encoding: 'application/json',
|
|
334
|
+
headers: this.getHeaders(reportedBy),
|
|
335
|
+
});
|
|
336
|
+
return result.data;
|
|
337
|
+
}
|
|
338
|
+
async verify(by, subject, handle, displayName, overrides) {
|
|
339
|
+
const res = await this.agent.app.bsky.graph.verification.create({ repo: by }, {
|
|
340
|
+
subject,
|
|
341
|
+
createdAt: new Date().toISOString(),
|
|
342
|
+
handle,
|
|
343
|
+
displayName,
|
|
344
|
+
...overrides,
|
|
345
|
+
}, this.getHeaders(by));
|
|
346
|
+
this.verifications[by] ??= {};
|
|
347
|
+
this.verifications[by][subject] = new AtUri(res.uri);
|
|
348
|
+
return this.verifications[by][subject];
|
|
349
|
+
}
|
|
350
|
+
async unverify(by, subject) {
|
|
351
|
+
const verification = this.verifications[by]?.[subject];
|
|
352
|
+
if (!verification) {
|
|
353
|
+
throw new Error('verification does not exist');
|
|
354
|
+
}
|
|
355
|
+
await this.agent.app.bsky.graph.verification.delete({ repo: by, rkey: verification.rkey }, this.getHeaders(by));
|
|
356
|
+
delete this.verifications[by][subject];
|
|
357
|
+
}
|
|
358
|
+
getHeaders(did) {
|
|
359
|
+
return SeedClient.getHeaders(this.accounts[did].accessJwt);
|
|
360
|
+
}
|
|
361
|
+
static getHeaders(jwt) {
|
|
362
|
+
return { authorization: `Bearer ${jwt}` };
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=client.js.map
|