-
Notifications
You must be signed in to change notification settings - Fork 403
/
basic.ts
147 lines (140 loc) · 3.7 KB
/
basic.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { SeedClient } from '@atproto/dev-env'
import { ids } from '../../src/lexicon/lexicons'
import usersSeed from './users'
export default async (sc: SeedClient, users = true) => {
if (users) await usersSeed(sc)
const alice = sc.dids.alice
const bob = sc.dids.bob
const carol = sc.dids.carol
const dan = sc.dids.dan
const createdAtMicroseconds = () => ({
createdAt: new Date().toISOString().replace('Z', '000Z'), // microseconds
})
const createdAtTimezone = () => ({
createdAt: new Date().toISOString().replace('Z', '+00:00'), // iso timezone format
})
await sc.follow(alice, bob)
await sc.follow(alice, carol)
await sc.follow(alice, dan)
await sc.follow(carol, alice)
await sc.follow(bob, alice)
await sc.follow(bob, carol, createdAtMicroseconds())
await sc.follow(dan, bob, createdAtTimezone())
await sc.post(alice, posts.alice[0], undefined, undefined, undefined, {
labels: {
$type: 'com.atproto.label.defs#selfLabels',
values: [{ val: 'self-label' }],
},
})
await sc.post(bob, posts.bob[0], undefined, undefined, undefined, {
langs: ['en-US', 'i-klingon'],
})
const img1 = await sc.uploadFile(
carol,
'tests/sample-img/key-landscape-small.jpg',
'image/jpeg',
)
const img2 = await sc.uploadFile(
carol,
'tests/sample-img/key-alt.jpg',
'image/jpeg',
)
await sc.post(
carol,
posts.carol[0],
undefined,
[img1, img2], // Contains both images and a quote
sc.posts[bob][0].ref,
)
await sc.post(dan, posts.dan[0])
await sc.post(
dan,
posts.dan[1],
[
{
index: { byteStart: 0, byteEnd: 18 },
features: [
{
$type: `${ids.AppBskyRichtextFacet}#mention`,
did: alice,
},
],
},
],
undefined,
sc.posts[carol][0].ref, // This post contains an images embed
)
await sc.post(
alice,
posts.alice[1],
undefined,
undefined,
undefined,
createdAtMicroseconds(),
)
await sc.post(
bob,
posts.bob[1],
undefined,
undefined,
undefined,
createdAtTimezone(),
)
await sc.post(
alice,
posts.alice[2],
undefined,
undefined,
sc.posts[dan][1].ref, // This post contains a record embed which contains an images embed
)
await sc.like(bob, sc.posts[alice][1].ref)
await sc.like(bob, sc.posts[alice][2].ref)
await sc.like(carol, sc.posts[alice][1].ref)
await sc.like(carol, sc.posts[alice][2].ref)
await sc.like(dan, sc.posts[alice][1].ref)
await sc.like(alice, sc.posts[carol][0].ref, createdAtMicroseconds())
await sc.like(bob, sc.posts[carol][0].ref, createdAtTimezone())
const replyImg = await sc.uploadFile(
bob,
'tests/sample-img/key-landscape-small.jpg',
'image/jpeg',
)
// must ensure ordering of replies in indexing
await sc.network.processAll()
await sc.reply(
bob,
sc.posts[alice][1].ref,
sc.posts[alice][1].ref,
replies.bob[0],
undefined,
[replyImg],
)
await sc.reply(
carol,
sc.posts[alice][1].ref,
sc.posts[alice][1].ref,
replies.carol[0],
)
await sc.network.processAll()
const alicesReplyToBob = await sc.reply(
alice,
sc.posts[alice][1].ref,
sc.replies[bob][0].ref,
replies.alice[0],
)
await sc.repost(carol, sc.posts[dan][1].ref)
await sc.repost(dan, sc.posts[alice][1].ref)
await sc.repost(dan, alicesReplyToBob.ref)
return sc
}
export const posts = {
alice: ['hey there', 'again', 'yoohoo label_me'],
bob: ['bob back at it again!', 'bobby boy here', 'yoohoo'],
carol: ['hi im carol'],
dan: ['dan here!', '@alice.bluesky.xyz is the best'],
}
export const replies = {
alice: ['thanks bob'],
bob: ['hear that label_me label_me_2'],
carol: ['of course'],
}