@atproto/dev-env 0.3.139 → 0.3.141
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 +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +49 -0
- package/dist/mock/index.js.map +1 -1
- package/dist/seed/thread-v2.d.ts +226 -0
- package/dist/seed/thread-v2.d.ts.map +1 -0
- package/dist/seed/thread-v2.js +768 -0
- package/dist/seed/thread-v2.js.map +1 -0
- package/package.json +7 -7
- package/src/index.ts +3 -0
- package/src/mock/index.ts +17 -0
- package/src/seed/thread-v2.ts +920 -0
- package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,768 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TAG_HIDE = exports.TAG_BUMP_DOWN = void 0;
|
4
|
+
exports.simple = simple;
|
5
|
+
exports.long = long;
|
6
|
+
exports.deep = deep;
|
7
|
+
exports.branchingFactor = branchingFactor;
|
8
|
+
exports.annotateMoreReplies = annotateMoreReplies;
|
9
|
+
exports.annotateOP = annotateOP;
|
10
|
+
exports.sort = sort;
|
11
|
+
exports.bumpOpAndViewer = bumpOpAndViewer;
|
12
|
+
exports.bumpGroupSorting = bumpGroupSorting;
|
13
|
+
exports.bumpFollows = bumpFollows;
|
14
|
+
exports.blockDeletionAuth = blockDeletionAuth;
|
15
|
+
exports.mutes = mutes;
|
16
|
+
exports.threadgated = threadgated;
|
17
|
+
exports.tags = tags;
|
18
|
+
function createUserStub(name) {
|
19
|
+
return {
|
20
|
+
id: name,
|
21
|
+
// @ts-ignore overwritten during seeding
|
22
|
+
did: undefined,
|
23
|
+
email: `${name}@test.com`,
|
24
|
+
handle: `${name}.test`,
|
25
|
+
password: `${name}-pass`,
|
26
|
+
displayName: name,
|
27
|
+
description: `hi im ${name} label_me`,
|
28
|
+
selfLabels: undefined,
|
29
|
+
};
|
30
|
+
}
|
31
|
+
async function createUsers(seedClient, prefix, handles) {
|
32
|
+
const stubs = handles.reduce((acc, handle) => {
|
33
|
+
acc[handle] = createUserStub(`${prefix}-${handle}`);
|
34
|
+
return acc;
|
35
|
+
}, {});
|
36
|
+
const users = await Promise.all(handles
|
37
|
+
.map((h) => prefix + '-' + h)
|
38
|
+
.map(async (handle) => {
|
39
|
+
const user = createUserStub(handle);
|
40
|
+
await seedClient.createAccount(handle, user);
|
41
|
+
user.did = seedClient.dids[handle];
|
42
|
+
return user;
|
43
|
+
}));
|
44
|
+
return users.reduce((acc, user) => {
|
45
|
+
const id = user.id.split('-')[1];
|
46
|
+
acc[id].did = user.did;
|
47
|
+
return acc;
|
48
|
+
}, stubs);
|
49
|
+
}
|
50
|
+
exports.TAG_BUMP_DOWN = 'down';
|
51
|
+
exports.TAG_HIDE = 'hide';
|
52
|
+
const rootReplyFnBuilder = (sc, root, parent, prevBreadcrumbs, posts) => {
|
53
|
+
let index = 0;
|
54
|
+
return async (replyAuthor, overridesOrCb, maybeReplyCb) => {
|
55
|
+
let overrides;
|
56
|
+
let replyCb;
|
57
|
+
if (overridesOrCb && typeof overridesOrCb === 'function') {
|
58
|
+
replyCb = overridesOrCb;
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
overrides = overridesOrCb;
|
62
|
+
replyCb = maybeReplyCb;
|
63
|
+
}
|
64
|
+
const breadcrumbs = prevBreadcrumbs
|
65
|
+
? `${prevBreadcrumbs}.${index++}`
|
66
|
+
: `${index++}`;
|
67
|
+
const text = breadcrumbs;
|
68
|
+
const reply = await sc.reply(replyAuthor.did, root, parent, text, undefined, undefined, overrides);
|
69
|
+
posts[breadcrumbs] = reply;
|
70
|
+
// Await for this post to be processed before replying to it.
|
71
|
+
replyCb && (await sc.network.processAll());
|
72
|
+
await replyCb?.(rootReplyFnBuilder(sc, root, reply.ref, breadcrumbs, posts));
|
73
|
+
};
|
74
|
+
};
|
75
|
+
const createThread = async (sc, rootAuthor, overridesOrCb, maybeReplyCb) => {
|
76
|
+
let overrides;
|
77
|
+
let replyCb;
|
78
|
+
if (overridesOrCb && typeof overridesOrCb === 'function') {
|
79
|
+
replyCb = overridesOrCb;
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
overrides = overridesOrCb;
|
83
|
+
replyCb = maybeReplyCb;
|
84
|
+
}
|
85
|
+
const replies = {};
|
86
|
+
const breadcrumbs = '';
|
87
|
+
const text = 'root';
|
88
|
+
const root = await sc.post(rootAuthor.did, text, undefined, undefined, undefined, overrides);
|
89
|
+
// Await for this post to be processed before replying to it.
|
90
|
+
replyCb && (await sc.network.processAll());
|
91
|
+
await replyCb?.(rootReplyFnBuilder(sc, root.ref, root.ref, breadcrumbs, replies));
|
92
|
+
return { root, replies };
|
93
|
+
};
|
94
|
+
async function simple(sc, prefix = 'simple') {
|
95
|
+
const users = await createUsers(sc, prefix, [
|
96
|
+
'op',
|
97
|
+
'alice',
|
98
|
+
'bob',
|
99
|
+
'carol',
|
100
|
+
]);
|
101
|
+
const { op, alice, bob, carol } = users;
|
102
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
103
|
+
await r(op, async (r) => {
|
104
|
+
await r(op);
|
105
|
+
});
|
106
|
+
await r(alice);
|
107
|
+
await r(bob, async (r) => {
|
108
|
+
await r(alice);
|
109
|
+
});
|
110
|
+
await r(carol);
|
111
|
+
});
|
112
|
+
return {
|
113
|
+
seedClient: sc,
|
114
|
+
users,
|
115
|
+
root,
|
116
|
+
r,
|
117
|
+
};
|
118
|
+
}
|
119
|
+
async function long(sc) {
|
120
|
+
const users = await createUsers(sc, 'long', [
|
121
|
+
'op',
|
122
|
+
'alice',
|
123
|
+
'bob',
|
124
|
+
'carol',
|
125
|
+
'dan',
|
126
|
+
]);
|
127
|
+
const { op, alice, bob, carol, dan } = users;
|
128
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
129
|
+
await r(op, async (r) => {
|
130
|
+
await r(op, async (r) => {
|
131
|
+
await r(op, async (r) => {
|
132
|
+
await r(op, async (r) => {
|
133
|
+
await r(op);
|
134
|
+
});
|
135
|
+
});
|
136
|
+
await r(op);
|
137
|
+
});
|
138
|
+
});
|
139
|
+
await r(alice);
|
140
|
+
await r(bob);
|
141
|
+
await r(carol);
|
142
|
+
await r(op, async (r) => {
|
143
|
+
await r(op, async (r) => {
|
144
|
+
await r(alice, async (r) => {
|
145
|
+
await r(op, async (r) => {
|
146
|
+
await r(op);
|
147
|
+
});
|
148
|
+
});
|
149
|
+
});
|
150
|
+
});
|
151
|
+
await r(alice);
|
152
|
+
await r(bob);
|
153
|
+
await r(carol);
|
154
|
+
});
|
155
|
+
await sc.like(op.did, r['5'].ref);
|
156
|
+
await sc.like(bob.did, r['5'].ref);
|
157
|
+
await sc.like(carol.did, r['5'].ref);
|
158
|
+
await sc.like(dan.did, r['5'].ref);
|
159
|
+
await sc.like(op.did, r['6'].ref);
|
160
|
+
await sc.like(alice.did, r['6'].ref);
|
161
|
+
await sc.like(carol.did, r['6'].ref);
|
162
|
+
await sc.like(op.did, r['7'].ref);
|
163
|
+
await sc.like(bob.did, r['7'].ref);
|
164
|
+
return {
|
165
|
+
seedClient: sc,
|
166
|
+
users,
|
167
|
+
root,
|
168
|
+
r,
|
169
|
+
};
|
170
|
+
}
|
171
|
+
async function deep(sc) {
|
172
|
+
const users = await createUsers(sc, 'deep', ['op']);
|
173
|
+
const { op } = users;
|
174
|
+
let counter = 0;
|
175
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
176
|
+
const recursiveReply = async (rFn) => {
|
177
|
+
if (counter < 18) {
|
178
|
+
counter++;
|
179
|
+
await rFn(op, async (r) => recursiveReply(r));
|
180
|
+
}
|
181
|
+
};
|
182
|
+
await recursiveReply(r);
|
183
|
+
});
|
184
|
+
return {
|
185
|
+
seedClient: sc,
|
186
|
+
users,
|
187
|
+
root,
|
188
|
+
r,
|
189
|
+
};
|
190
|
+
}
|
191
|
+
async function branchingFactor(sc) {
|
192
|
+
const users = await createUsers(sc, 'bf', ['op', 'bob']);
|
193
|
+
const { op, bob } = users;
|
194
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
195
|
+
await r(bob, async (r) => {
|
196
|
+
await r(bob, async (r) => {
|
197
|
+
await r(bob);
|
198
|
+
await r(bob);
|
199
|
+
await r(bob);
|
200
|
+
await r(bob);
|
201
|
+
});
|
202
|
+
await r(bob, async (r) => {
|
203
|
+
await r(bob);
|
204
|
+
await r(bob);
|
205
|
+
await r(bob);
|
206
|
+
await r(bob);
|
207
|
+
});
|
208
|
+
await r(bob, async (r) => {
|
209
|
+
await r(bob);
|
210
|
+
await r(bob);
|
211
|
+
await r(bob);
|
212
|
+
await r(bob);
|
213
|
+
});
|
214
|
+
await r(bob, async (r) => {
|
215
|
+
await r(bob);
|
216
|
+
await r(bob);
|
217
|
+
await r(bob);
|
218
|
+
await r(bob);
|
219
|
+
});
|
220
|
+
});
|
221
|
+
await r(bob, async (r) => {
|
222
|
+
await r(bob, async (r) => {
|
223
|
+
// This is the only case in this seed where a reply has 1 reply instead of 4,
|
224
|
+
// to have cases of different lengths in the same tree.
|
225
|
+
await r(bob);
|
226
|
+
});
|
227
|
+
await r(bob, async (r) => {
|
228
|
+
await r(bob);
|
229
|
+
await r(bob);
|
230
|
+
await r(bob);
|
231
|
+
await r(bob);
|
232
|
+
});
|
233
|
+
await r(bob, async (r) => {
|
234
|
+
await r(bob);
|
235
|
+
await r(bob);
|
236
|
+
await r(bob);
|
237
|
+
await r(bob);
|
238
|
+
});
|
239
|
+
await r(bob, async (r) => {
|
240
|
+
await r(bob);
|
241
|
+
await r(bob);
|
242
|
+
await r(bob);
|
243
|
+
await r(bob);
|
244
|
+
});
|
245
|
+
});
|
246
|
+
await r(bob, async (r) => {
|
247
|
+
await r(bob, async (r) => {
|
248
|
+
await r(bob);
|
249
|
+
await r(bob);
|
250
|
+
await r(bob);
|
251
|
+
await r(bob);
|
252
|
+
});
|
253
|
+
await r(bob, async (r) => {
|
254
|
+
await r(bob);
|
255
|
+
await r(bob);
|
256
|
+
await r(bob);
|
257
|
+
await r(bob);
|
258
|
+
});
|
259
|
+
await r(bob, async (r) => {
|
260
|
+
await r(bob);
|
261
|
+
await r(bob);
|
262
|
+
await r(bob);
|
263
|
+
await r(bob);
|
264
|
+
});
|
265
|
+
await r(bob, async (r) => {
|
266
|
+
await r(bob);
|
267
|
+
await r(bob);
|
268
|
+
await r(bob);
|
269
|
+
await r(bob);
|
270
|
+
});
|
271
|
+
});
|
272
|
+
await r(bob, async (r) => {
|
273
|
+
await r(bob, async (r) => {
|
274
|
+
await r(bob);
|
275
|
+
await r(bob);
|
276
|
+
await r(bob);
|
277
|
+
await r(bob);
|
278
|
+
// This is the only case in this seed where a reply has 5 replies instead of 4,
|
279
|
+
// to have cases of different lengths in the same tree.
|
280
|
+
await r(bob);
|
281
|
+
});
|
282
|
+
await r(bob, async (r) => {
|
283
|
+
await r(bob);
|
284
|
+
await r(bob);
|
285
|
+
await r(bob);
|
286
|
+
await r(bob);
|
287
|
+
});
|
288
|
+
await r(bob, async (r) => {
|
289
|
+
await r(bob);
|
290
|
+
await r(bob);
|
291
|
+
await r(bob);
|
292
|
+
await r(bob);
|
293
|
+
});
|
294
|
+
await r(bob, async (r) => {
|
295
|
+
await r(bob);
|
296
|
+
await r(bob);
|
297
|
+
await r(bob);
|
298
|
+
await r(bob);
|
299
|
+
});
|
300
|
+
});
|
301
|
+
});
|
302
|
+
return {
|
303
|
+
seedClient: sc,
|
304
|
+
users,
|
305
|
+
root,
|
306
|
+
r,
|
307
|
+
};
|
308
|
+
}
|
309
|
+
async function annotateMoreReplies(sc) {
|
310
|
+
const users = await createUsers(sc, 'mr', ['op', 'alice']);
|
311
|
+
const { op, alice } = users;
|
312
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
313
|
+
await r(alice, async (r) => {
|
314
|
+
await r(alice, async (r) => {
|
315
|
+
await r(alice, async (r) => {
|
316
|
+
await r(alice, async (r) => {
|
317
|
+
// more replies... (below = 4)
|
318
|
+
await r(alice, async (r) => {
|
319
|
+
await r(alice);
|
320
|
+
});
|
321
|
+
await r(alice);
|
322
|
+
await r(alice, async (r) => {
|
323
|
+
await r(alice, async (r) => {
|
324
|
+
await r(alice);
|
325
|
+
});
|
326
|
+
});
|
327
|
+
await r(alice);
|
328
|
+
await r(alice);
|
329
|
+
});
|
330
|
+
});
|
331
|
+
});
|
332
|
+
await r(alice, async (r) => {
|
333
|
+
await r(alice, async (r) => {
|
334
|
+
await r(alice);
|
335
|
+
});
|
336
|
+
});
|
337
|
+
});
|
338
|
+
await r(alice, async (r) => {
|
339
|
+
await r(alice, async (r) => {
|
340
|
+
await r(alice);
|
341
|
+
await r(alice);
|
342
|
+
// more replies... (branchingFactor = 2)
|
343
|
+
await r(alice);
|
344
|
+
await r(alice);
|
345
|
+
await r(alice);
|
346
|
+
});
|
347
|
+
await r(alice, async (r) => {
|
348
|
+
await r(alice);
|
349
|
+
await r(alice);
|
350
|
+
});
|
351
|
+
// more replies... (branchingFactor = 2)
|
352
|
+
await r(alice);
|
353
|
+
});
|
354
|
+
await r(alice); // anchor reply not limited by branchingFactor
|
355
|
+
});
|
356
|
+
return {
|
357
|
+
seedClient: sc,
|
358
|
+
users,
|
359
|
+
root,
|
360
|
+
r,
|
361
|
+
};
|
362
|
+
}
|
363
|
+
async function annotateOP(sc) {
|
364
|
+
const users = await createUsers(sc, 'op', ['op', 'alice', 'bob']);
|
365
|
+
const { op, alice, bob } = users;
|
366
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
367
|
+
await r(op, async (r) => {
|
368
|
+
await r(op, async (r) => {
|
369
|
+
await r(op);
|
370
|
+
});
|
371
|
+
});
|
372
|
+
await r(alice, async (r) => {
|
373
|
+
await r(alice);
|
374
|
+
});
|
375
|
+
await r(op, async (r) => {
|
376
|
+
await r(bob, async (r) => {
|
377
|
+
await r(op);
|
378
|
+
});
|
379
|
+
});
|
380
|
+
});
|
381
|
+
return {
|
382
|
+
seedClient: sc,
|
383
|
+
users,
|
384
|
+
root,
|
385
|
+
r,
|
386
|
+
};
|
387
|
+
}
|
388
|
+
async function sort(sc) {
|
389
|
+
const users = await createUsers(sc, 'sort', [
|
390
|
+
'op',
|
391
|
+
'alice',
|
392
|
+
'bob',
|
393
|
+
'carol',
|
394
|
+
]);
|
395
|
+
const { op, alice, bob, carol } = users;
|
396
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
397
|
+
// 0 likes
|
398
|
+
await r(alice, async (r) => {
|
399
|
+
await r(carol); // 0 likes
|
400
|
+
await r(alice); // 2 likes
|
401
|
+
await r(bob); // 1 like
|
402
|
+
});
|
403
|
+
// 3 likes
|
404
|
+
await r(carol, async (r) => {
|
405
|
+
await r(bob); // 1 like
|
406
|
+
await r(carol); // 2 likes
|
407
|
+
await r(alice); // 0 likes
|
408
|
+
});
|
409
|
+
// 2 likes
|
410
|
+
await r(bob, async (r) => {
|
411
|
+
await r(bob); // 2 likes
|
412
|
+
await r(alice); // 1 like
|
413
|
+
await r(carol); // 0 likes
|
414
|
+
});
|
415
|
+
});
|
416
|
+
// likes depth 1
|
417
|
+
await sc.like(alice.did, r['2'].ref);
|
418
|
+
await sc.like(carol.did, r['2'].ref);
|
419
|
+
await sc.like(op.did, r['1'].ref); // op like
|
420
|
+
await sc.like(bob.did, r['1'].ref);
|
421
|
+
await sc.like(carol.did, r['1'].ref);
|
422
|
+
// likes depth 2
|
423
|
+
await sc.like(bob.did, r['0.1'].ref);
|
424
|
+
await sc.like(carol.did, r['0.1'].ref);
|
425
|
+
await sc.like(op.did, r['0.2'].ref); // op like
|
426
|
+
await sc.like(bob.did, r['1.1'].ref);
|
427
|
+
await sc.like(carol.did, r['1.1'].ref);
|
428
|
+
await sc.like(bob.did, r['1.0'].ref);
|
429
|
+
await sc.like(bob.did, r['2.0'].ref);
|
430
|
+
await sc.like(carol.did, r['2.0'].ref);
|
431
|
+
await sc.like(bob.did, r['2.1'].ref);
|
432
|
+
return {
|
433
|
+
seedClient: sc,
|
434
|
+
users,
|
435
|
+
root,
|
436
|
+
r,
|
437
|
+
};
|
438
|
+
}
|
439
|
+
async function bumpOpAndViewer(sc) {
|
440
|
+
const users = await createUsers(sc, 'bumpOV', [
|
441
|
+
'op',
|
442
|
+
'viewer',
|
443
|
+
'alice',
|
444
|
+
'bob',
|
445
|
+
'carol',
|
446
|
+
]);
|
447
|
+
const { op, viewer, alice, bob, carol } = users;
|
448
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
449
|
+
// 1 like
|
450
|
+
await r(alice, async (r) => {
|
451
|
+
await r(carol); // 0 likes
|
452
|
+
await r(alice); // 2 likes
|
453
|
+
await r(bob); // 1 like
|
454
|
+
await r(viewer); // 0 likes
|
455
|
+
await r(op); // 0 likes
|
456
|
+
});
|
457
|
+
// 3 likes
|
458
|
+
await r(carol, async (r) => {
|
459
|
+
await r(bob); // 1 like
|
460
|
+
await r(carol); // 2 likes
|
461
|
+
await r(op); // 0 likes
|
462
|
+
await r(viewer); // 1 like
|
463
|
+
await r(alice); // 0 likes
|
464
|
+
});
|
465
|
+
// 2 likes
|
466
|
+
await r(bob, async (r) => {
|
467
|
+
await r(viewer); // 0 likes
|
468
|
+
await r(bob); // 4 likes
|
469
|
+
await r(op); // 0 likes
|
470
|
+
await r(alice); // 1 like
|
471
|
+
await r(carol); // 1 like
|
472
|
+
});
|
473
|
+
// 0 likes
|
474
|
+
await r(op, async (r) => {
|
475
|
+
await r(viewer); // 0 likes
|
476
|
+
await r(bob); // 0 likes
|
477
|
+
await r(op); // 0 likes
|
478
|
+
await r(alice); // 0 likes
|
479
|
+
await r(carol); // 0 likes
|
480
|
+
});
|
481
|
+
// 0 likes
|
482
|
+
await r(viewer, async (r) => {
|
483
|
+
await r(bob); // 1 like
|
484
|
+
await r(carol); // 1 like
|
485
|
+
await r(op); // 0 likes
|
486
|
+
await r(viewer); // 0 likes
|
487
|
+
await r(alice); // 0 likes
|
488
|
+
});
|
489
|
+
});
|
490
|
+
// likes depth 1
|
491
|
+
await sc.like(alice.did, r['2'].ref);
|
492
|
+
await sc.like(carol.did, r['2'].ref);
|
493
|
+
await sc.like(viewer.did, r['0'].ref);
|
494
|
+
await sc.like(op.did, r['1'].ref); // op like
|
495
|
+
await sc.like(bob.did, r['1'].ref);
|
496
|
+
await sc.like(carol.did, r['1'].ref);
|
497
|
+
// likes depth 2
|
498
|
+
await sc.like(bob.did, r['0.1'].ref);
|
499
|
+
await sc.like(carol.did, r['0.1'].ref);
|
500
|
+
await sc.like(op.did, r['0.2'].ref); // op like
|
501
|
+
await sc.like(bob.did, r['1.1'].ref);
|
502
|
+
await sc.like(carol.did, r['1.1'].ref);
|
503
|
+
await sc.like(bob.did, r['1.0'].ref);
|
504
|
+
await sc.like(alice.did, r['2.1'].ref);
|
505
|
+
await sc.like(bob.did, r['2.1'].ref);
|
506
|
+
await sc.like(carol.did, r['2.1'].ref);
|
507
|
+
await sc.like(viewer.did, r['2.1'].ref);
|
508
|
+
await sc.like(bob.did, r['1.3'].ref);
|
509
|
+
await sc.like(bob.did, r['2.3'].ref);
|
510
|
+
await sc.like(viewer.did, r['2.4'].ref);
|
511
|
+
await sc.like(viewer.did, r['4.0'].ref);
|
512
|
+
await sc.like(alice.did, r['4.1'].ref);
|
513
|
+
return {
|
514
|
+
seedClient: sc,
|
515
|
+
users,
|
516
|
+
root,
|
517
|
+
r,
|
518
|
+
};
|
519
|
+
}
|
520
|
+
async function bumpGroupSorting(sc) {
|
521
|
+
const users = await createUsers(sc, 'bumpGS', [
|
522
|
+
'op',
|
523
|
+
'viewer',
|
524
|
+
'alice',
|
525
|
+
]);
|
526
|
+
const { op, viewer, alice } = users;
|
527
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
528
|
+
await r(viewer);
|
529
|
+
await r(op);
|
530
|
+
await r(alice);
|
531
|
+
await r(op);
|
532
|
+
await r(viewer);
|
533
|
+
await r(op);
|
534
|
+
await r(alice);
|
535
|
+
await r(viewer);
|
536
|
+
});
|
537
|
+
return {
|
538
|
+
seedClient: sc,
|
539
|
+
users,
|
540
|
+
root,
|
541
|
+
r,
|
542
|
+
};
|
543
|
+
}
|
544
|
+
async function bumpFollows(sc) {
|
545
|
+
const users = await createUsers(sc, 'bumpF', [
|
546
|
+
'op',
|
547
|
+
'viewerF',
|
548
|
+
'viewerNoF',
|
549
|
+
'alice',
|
550
|
+
'bob',
|
551
|
+
'carol',
|
552
|
+
]);
|
553
|
+
const { op, viewerF, viewerNoF, alice, bob, carol } = users;
|
554
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
555
|
+
await r(alice);
|
556
|
+
await r(bob);
|
557
|
+
await r(carol);
|
558
|
+
await r(op);
|
559
|
+
await r(viewerF);
|
560
|
+
await r(viewerNoF);
|
561
|
+
});
|
562
|
+
await sc.follow(viewerF.did, alice.did);
|
563
|
+
await sc.follow(viewerF.did, bob.did);
|
564
|
+
// Does not follow carol.
|
565
|
+
return {
|
566
|
+
seedClient: sc,
|
567
|
+
users,
|
568
|
+
root,
|
569
|
+
r,
|
570
|
+
};
|
571
|
+
}
|
572
|
+
async function blockDeletionAuth(sc, labelerDid) {
|
573
|
+
const users = await createUsers(sc, 'bda', [
|
574
|
+
'op',
|
575
|
+
'opBlocked',
|
576
|
+
'alice',
|
577
|
+
'auth',
|
578
|
+
'blocker',
|
579
|
+
'blocked',
|
580
|
+
]);
|
581
|
+
const { op, opBlocked, alice, auth, blocker, blocked } = users;
|
582
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
583
|
+
// 1p block, hidden for `blocked`.
|
584
|
+
await r(blocker, async (r) => {
|
585
|
+
await r(alice);
|
586
|
+
});
|
587
|
+
// 3p block, hidden for all.
|
588
|
+
await r(opBlocked, async (r) => {
|
589
|
+
await r(op);
|
590
|
+
await r(alice);
|
591
|
+
});
|
592
|
+
// Deleted, hidden for all.
|
593
|
+
await r(alice, async (r) => {
|
594
|
+
await r(alice);
|
595
|
+
});
|
596
|
+
// User configured to only be seend by authenticated users.
|
597
|
+
// Requires the test sets a `!no-unauthenticated` label for this user.
|
598
|
+
await r(auth, async (r) => {
|
599
|
+
// Another auth-only to show that the parent chain is preserved in the thread.
|
600
|
+
await r(auth, async (r) => {
|
601
|
+
await r(alice);
|
602
|
+
});
|
603
|
+
});
|
604
|
+
});
|
605
|
+
await sc.deletePost(alice.did, r['2'].ref.uri);
|
606
|
+
await sc.block(blocker.did, blocked.did);
|
607
|
+
await sc.block(op.did, opBlocked.did);
|
608
|
+
const db = sc.network.bsky.db.db;
|
609
|
+
await createLabel(db, {
|
610
|
+
src: labelerDid,
|
611
|
+
uri: auth.did,
|
612
|
+
cid: '',
|
613
|
+
val: '!no-unauthenticated',
|
614
|
+
});
|
615
|
+
return {
|
616
|
+
seedClient: sc,
|
617
|
+
users,
|
618
|
+
root,
|
619
|
+
r,
|
620
|
+
};
|
621
|
+
}
|
622
|
+
async function mutes(sc) {
|
623
|
+
const users = await createUsers(sc, 'mutes', [
|
624
|
+
'op',
|
625
|
+
'opMuted',
|
626
|
+
'alice',
|
627
|
+
'muted',
|
628
|
+
'muter',
|
629
|
+
]);
|
630
|
+
const { op, opMuted, alice, muted, muter } = users;
|
631
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
632
|
+
await r(opMuted, async (r) => {
|
633
|
+
await r(alice);
|
634
|
+
await r(muted);
|
635
|
+
});
|
636
|
+
await r(muted, async (r) => {
|
637
|
+
await r(opMuted);
|
638
|
+
await r(alice);
|
639
|
+
});
|
640
|
+
});
|
641
|
+
await sc.mute(op.did, opMuted.did);
|
642
|
+
await sc.mute(muter.did, muted.did);
|
643
|
+
return {
|
644
|
+
seedClient: sc,
|
645
|
+
users,
|
646
|
+
root,
|
647
|
+
r,
|
648
|
+
};
|
649
|
+
}
|
650
|
+
async function threadgated(sc) {
|
651
|
+
const users = await createUsers(sc, 'tg', [
|
652
|
+
'op',
|
653
|
+
'opMuted',
|
654
|
+
'viewer',
|
655
|
+
'alice',
|
656
|
+
'bob',
|
657
|
+
]);
|
658
|
+
const { op, opMuted, alice, bob } = users;
|
659
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
660
|
+
// Muted moves down below threadgated.
|
661
|
+
await r(opMuted);
|
662
|
+
// Threadgated moves down.
|
663
|
+
await r(alice, async (r) => {
|
664
|
+
await r(alice);
|
665
|
+
await r(bob);
|
666
|
+
await r(op); // OP moves up.
|
667
|
+
});
|
668
|
+
await r(bob, async (r) => {
|
669
|
+
await r(alice);
|
670
|
+
await r(bob); // Threadgated is omitted if fetched from the root.
|
671
|
+
await r(op); // OP moves down.
|
672
|
+
});
|
673
|
+
});
|
674
|
+
await sc.agent.app.bsky.feed.threadgate.create({
|
675
|
+
repo: op.did,
|
676
|
+
rkey: root.ref.uri.rkey,
|
677
|
+
}, {
|
678
|
+
post: root.ref.uriStr,
|
679
|
+
createdAt: new Date().toISOString(),
|
680
|
+
hiddenReplies: [r['1'].ref.uriStr, r['2.1'].ref.uriStr],
|
681
|
+
}, sc.getHeaders(op.did));
|
682
|
+
// Just throw a mute there to test the prioritization between muted and threadgated.
|
683
|
+
await sc.mute(op.did, opMuted.did);
|
684
|
+
return {
|
685
|
+
seedClient: sc,
|
686
|
+
users,
|
687
|
+
root,
|
688
|
+
r,
|
689
|
+
};
|
690
|
+
}
|
691
|
+
async function tags(sc) {
|
692
|
+
const users = await createUsers(sc, 'tags', [
|
693
|
+
'op',
|
694
|
+
'alice',
|
695
|
+
'down',
|
696
|
+
'following',
|
697
|
+
'hide',
|
698
|
+
'viewer',
|
699
|
+
]);
|
700
|
+
const { op, alice, down, following, hide, viewer } = users;
|
701
|
+
const { root, replies: r } = await createThread(sc, op, async (r) => {
|
702
|
+
await r(alice, async (r) => {
|
703
|
+
await r(alice);
|
704
|
+
await r(down);
|
705
|
+
await r(hide);
|
706
|
+
});
|
707
|
+
await r(down, async (r) => {
|
708
|
+
await r(alice);
|
709
|
+
await r(down);
|
710
|
+
await r(hide);
|
711
|
+
});
|
712
|
+
await r(hide, async (r) => {
|
713
|
+
await r(alice);
|
714
|
+
await r(down);
|
715
|
+
await r(hide);
|
716
|
+
});
|
717
|
+
await r(op);
|
718
|
+
await r(viewer);
|
719
|
+
await r(following);
|
720
|
+
});
|
721
|
+
await sc.network.processAll();
|
722
|
+
await sc.follow(viewer.did, following.did);
|
723
|
+
const db = sc.network.bsky.db.db;
|
724
|
+
await createTag(db, { uri: r['1'].ref.uriStr, val: exports.TAG_BUMP_DOWN });
|
725
|
+
await createTag(db, { uri: r['0.1'].ref.uriStr, val: exports.TAG_BUMP_DOWN });
|
726
|
+
await createTag(db, { uri: r['1.1'].ref.uriStr, val: exports.TAG_BUMP_DOWN });
|
727
|
+
await createTag(db, { uri: r['2.1'].ref.uriStr, val: exports.TAG_BUMP_DOWN });
|
728
|
+
await createTag(db, { uri: r['2'].ref.uriStr, val: exports.TAG_HIDE });
|
729
|
+
await createTag(db, { uri: r['0.2'].ref.uriStr, val: exports.TAG_HIDE });
|
730
|
+
await createTag(db, { uri: r['1.2'].ref.uriStr, val: exports.TAG_HIDE });
|
731
|
+
await createTag(db, { uri: r['2.2'].ref.uriStr, val: exports.TAG_HIDE });
|
732
|
+
// Neither tag affect op, viewer.
|
733
|
+
await createTag(db, { uri: r['3'].ref.uriStr, val: exports.TAG_BUMP_DOWN });
|
734
|
+
await createTag(db, { uri: r['4'].ref.uriStr, val: exports.TAG_HIDE });
|
735
|
+
// Tags affect following depending on the config to prioritize following.
|
736
|
+
await createTag(db, { uri: r['5'].ref.uriStr, val: exports.TAG_HIDE });
|
737
|
+
return {
|
738
|
+
seedClient: sc,
|
739
|
+
users,
|
740
|
+
root,
|
741
|
+
r,
|
742
|
+
};
|
743
|
+
}
|
744
|
+
const createLabel = async (db, opts) => {
|
745
|
+
await db
|
746
|
+
.insertInto('label')
|
747
|
+
.values({
|
748
|
+
uri: opts.uri,
|
749
|
+
cid: opts.cid,
|
750
|
+
val: opts.val,
|
751
|
+
cts: new Date().toISOString(),
|
752
|
+
exp: opts.exp ?? null,
|
753
|
+
neg: false,
|
754
|
+
src: opts.src,
|
755
|
+
})
|
756
|
+
.execute();
|
757
|
+
};
|
758
|
+
const createTag = async (db, opts) => {
|
759
|
+
await db
|
760
|
+
.updateTable('record')
|
761
|
+
.set({
|
762
|
+
tags: JSON.stringify([opts.val]),
|
763
|
+
})
|
764
|
+
.where('uri', '=', opts.uri)
|
765
|
+
.returningAll()
|
766
|
+
.execute();
|
767
|
+
};
|
768
|
+
//# sourceMappingURL=thread-v2.js.map
|