@atproto/dev-env 0.3.34-rc.0 → 0.3.34
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -32
- package/dist/bsky.d.ts.map +1 -1
- package/dist/bsky.js +1 -1
- package/dist/bsky.js.map +1 -1
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +72 -54
- package/dist/mock/index.js.map +1 -1
- package/dist/moderator-client.d.ts +1 -1
- package/dist/moderator-client.d.ts.map +1 -1
- package/dist/moderator-client.js +5 -5
- package/dist/moderator-client.js.map +1 -1
- package/dist/ozone-service-profile.d.ts.map +1 -1
- package/dist/ozone-service-profile.js +12 -11
- package/dist/ozone-service-profile.js.map +1 -1
- package/dist/ozone.d.ts.map +1 -1
- package/dist/ozone.js +1 -3
- package/dist/ozone.js.map +1 -1
- package/dist/pds.js +1 -1
- package/dist/pds.js.map +1 -1
- package/dist/seed/client.d.ts +2 -2
- package/dist/seed/client.d.ts.map +1 -1
- package/dist/seed/client.js +21 -21
- package/dist/seed/client.js.map +1 -1
- package/package.json +8 -8
- package/src/bsky.ts +2 -2
- package/src/mock/index.ts +114 -95
- package/src/moderator-client.ts +11 -9
- package/src/ozone-service-profile.ts +29 -21
- package/src/ozone.ts +3 -5
- package/src/pds.ts +1 -1
- package/src/seed/client.ts +23 -30
package/src/seed/client.ts
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
import fs from 'fs/promises'
|
2
2
|
import { CID } from 'multiformats/cid'
|
3
|
-
import {
|
3
|
+
import AtpAgent, {
|
4
4
|
ComAtprotoModerationCreateReport,
|
5
5
|
AppBskyFeedPost,
|
6
6
|
AppBskyRichtextFacet,
|
7
7
|
AppBskyFeedLike,
|
8
8
|
AppBskyGraphFollow,
|
9
9
|
AppBskyGraphList,
|
10
|
-
AtpAgent,
|
11
10
|
} from '@atproto/api'
|
12
11
|
import { AtUri } from '@atproto/syntax'
|
13
12
|
import { BlobRef } from '@atproto/lexicon'
|
@@ -134,7 +133,7 @@ export class SeedClient<
|
|
134
133
|
},
|
135
134
|
) {
|
136
135
|
const { data: account } =
|
137
|
-
await this.agent.com.atproto.server.createAccount(params)
|
136
|
+
await this.agent.api.com.atproto.server.createAccount(params)
|
138
137
|
this.dids[shortName] = account.did
|
139
138
|
this.accounts[account.did] = {
|
140
139
|
...account,
|
@@ -145,7 +144,7 @@ export class SeedClient<
|
|
145
144
|
}
|
146
145
|
|
147
146
|
async updateHandle(by: string, handle: string) {
|
148
|
-
await this.agent.com.atproto.identity.updateHandle(
|
147
|
+
await this.agent.api.com.atproto.identity.updateHandle(
|
149
148
|
{ handle },
|
150
149
|
{ encoding: 'application/json', headers: this.getHeaders(by) },
|
151
150
|
)
|
@@ -157,20 +156,14 @@ export class SeedClient<
|
|
157
156
|
description: string,
|
158
157
|
selfLabels?: string[],
|
159
158
|
joinedViaStarterPack?: RecordRef,
|
160
|
-
)
|
161
|
-
displayName: string
|
162
|
-
description: string
|
163
|
-
avatar: { cid: string; mimeType: string }
|
164
|
-
ref: RecordRef
|
165
|
-
joinedViaStarterPack?: RecordRef
|
166
|
-
}> {
|
159
|
+
) {
|
167
160
|
AVATAR_IMG ??= await fs.readFile(
|
168
161
|
'../dev-env/src/seed/img/key-portrait-small.jpg',
|
169
162
|
)
|
170
163
|
|
171
164
|
let avatarBlob
|
172
165
|
{
|
173
|
-
const res = await this.agent.com.atproto.repo.uploadBlob(AVATAR_IMG, {
|
166
|
+
const res = await this.agent.api.com.atproto.repo.uploadBlob(AVATAR_IMG, {
|
174
167
|
encoding: 'image/jpeg',
|
175
168
|
headers: this.getHeaders(by),
|
176
169
|
} as any)
|
@@ -178,7 +171,7 @@ export class SeedClient<
|
|
178
171
|
}
|
179
172
|
|
180
173
|
{
|
181
|
-
const res = await this.agent.app.bsky.actor.profile.create(
|
174
|
+
const res = await this.agent.api.app.bsky.actor.profile.create(
|
182
175
|
{ repo: by },
|
183
176
|
{
|
184
177
|
displayName,
|
@@ -207,7 +200,7 @@ export class SeedClient<
|
|
207
200
|
}
|
208
201
|
|
209
202
|
async updateProfile(by: string, record: Record<string, unknown>) {
|
210
|
-
const res = await this.agent.com.atproto.repo.putRecord(
|
203
|
+
const res = await this.agent.api.com.atproto.repo.putRecord(
|
211
204
|
{
|
212
205
|
repo: by,
|
213
206
|
collection: 'app.bsky.actor.profile',
|
@@ -229,7 +222,7 @@ export class SeedClient<
|
|
229
222
|
to: string,
|
230
223
|
overrides?: Partial<AppBskyGraphFollow.Record>,
|
231
224
|
) {
|
232
|
-
const res = await this.agent.app.bsky.graph.follow.create(
|
225
|
+
const res = await this.agent.api.app.bsky.graph.follow.create(
|
233
226
|
{ repo: from },
|
234
227
|
{
|
235
228
|
subject: to,
|
@@ -248,7 +241,7 @@ export class SeedClient<
|
|
248
241
|
if (!follow) {
|
249
242
|
throw new Error('follow does not exist')
|
250
243
|
}
|
251
|
-
await this.agent.app.bsky.graph.follow.delete(
|
244
|
+
await this.agent.api.app.bsky.graph.follow.delete(
|
252
245
|
{ repo: from, rkey: follow.uri.rkey },
|
253
246
|
this.getHeaders(from),
|
254
247
|
)
|
@@ -260,7 +253,7 @@ export class SeedClient<
|
|
260
253
|
to: string,
|
261
254
|
overrides?: Partial<AppBskyGraphFollow.Record>,
|
262
255
|
) {
|
263
|
-
const res = await this.agent.app.bsky.graph.block.create(
|
256
|
+
const res = await this.agent.api.app.bsky.graph.block.create(
|
264
257
|
{ repo: from },
|
265
258
|
{
|
266
259
|
subject: to,
|
@@ -279,7 +272,7 @@ export class SeedClient<
|
|
279
272
|
if (!block) {
|
280
273
|
throw new Error('block does not exist')
|
281
274
|
}
|
282
|
-
await this.agent.app.bsky.graph.block.delete(
|
275
|
+
await this.agent.api.app.bsky.graph.block.delete(
|
283
276
|
{ repo: from, rkey: block.uri.rkey },
|
284
277
|
this.getHeaders(from),
|
285
278
|
)
|
@@ -311,7 +304,7 @@ export class SeedClient<
|
|
311
304
|
: recordEmbed
|
312
305
|
? { $type: 'app.bsky.embed.record', ...recordEmbed }
|
313
306
|
: imageEmbed
|
314
|
-
const res = await this.agent.app.bsky.feed.post.create(
|
307
|
+
const res = await this.agent.api.app.bsky.feed.post.create(
|
315
308
|
{ repo: by },
|
316
309
|
{
|
317
310
|
text: text,
|
@@ -334,7 +327,7 @@ export class SeedClient<
|
|
334
327
|
}
|
335
328
|
|
336
329
|
async deletePost(by: string, uri: AtUri) {
|
337
|
-
await this.agent.app.bsky.feed.post.delete(
|
330
|
+
await this.agent.api.app.bsky.feed.post.delete(
|
338
331
|
{
|
339
332
|
repo: by,
|
340
333
|
rkey: uri.rkey,
|
@@ -349,7 +342,7 @@ export class SeedClient<
|
|
349
342
|
encoding: string,
|
350
343
|
): Promise<ImageRef> {
|
351
344
|
const file = await fs.readFile(filePath)
|
352
|
-
const res = await this.agent.com.atproto.repo.uploadBlob(file, {
|
345
|
+
const res = await this.agent.api.com.atproto.repo.uploadBlob(file, {
|
353
346
|
headers: this.getHeaders(by),
|
354
347
|
encoding,
|
355
348
|
} as any)
|
@@ -361,7 +354,7 @@ export class SeedClient<
|
|
361
354
|
subject: RecordRef,
|
362
355
|
overrides?: Partial<AppBskyFeedLike.Record>,
|
363
356
|
) {
|
364
|
-
const res = await this.agent.app.bsky.feed.like.create(
|
357
|
+
const res = await this.agent.api.app.bsky.feed.like.create(
|
365
358
|
{ repo: by },
|
366
359
|
{
|
367
360
|
subject: subject.raw,
|
@@ -389,7 +382,7 @@ export class SeedClient<
|
|
389
382
|
images,
|
390
383
|
}
|
391
384
|
: undefined
|
392
|
-
const res = await this.agent.app.bsky.feed.post.create(
|
385
|
+
const res = await this.agent.api.app.bsky.feed.post.create(
|
393
386
|
{ repo: by },
|
394
387
|
{
|
395
388
|
text: text,
|
@@ -414,7 +407,7 @@ export class SeedClient<
|
|
414
407
|
}
|
415
408
|
|
416
409
|
async repost(by: string, subject: RecordRef) {
|
417
|
-
const res = await this.agent.app.bsky.feed.repost.create(
|
410
|
+
const res = await this.agent.api.app.bsky.feed.repost.create(
|
418
411
|
{ repo: by },
|
419
412
|
{ subject: subject.raw, createdAt: new Date().toISOString() },
|
420
413
|
this.getHeaders(by),
|
@@ -431,7 +424,7 @@ export class SeedClient<
|
|
431
424
|
purpose: 'mod' | 'curate' | 'reference',
|
432
425
|
overrides?: Partial<AppBskyGraphList.Record>,
|
433
426
|
) {
|
434
|
-
const res = await this.agent.app.bsky.graph.list.create(
|
427
|
+
const res = await this.agent.api.app.bsky.graph.list.create(
|
435
428
|
{ repo: by },
|
436
429
|
{
|
437
430
|
name,
|
@@ -456,7 +449,7 @@ export class SeedClient<
|
|
456
449
|
}
|
457
450
|
|
458
451
|
async createFeedGen(by: string, feedDid: string, name: string) {
|
459
|
-
const res = await this.agent.app.bsky.feed.generator.create(
|
452
|
+
const res = await this.agent.api.app.bsky.feed.generator.create(
|
460
453
|
{ repo: by },
|
461
454
|
{
|
462
455
|
did: feedDid,
|
@@ -484,7 +477,7 @@ export class SeedClient<
|
|
484
477
|
for (const did of actors) {
|
485
478
|
await this.addToList(by, did, list)
|
486
479
|
}
|
487
|
-
const res = await this.agent.app.bsky.graph.starterpack.create(
|
480
|
+
const res = await this.agent.api.app.bsky.graph.starterpack.create(
|
488
481
|
{ repo: by },
|
489
482
|
{
|
490
483
|
name,
|
@@ -506,7 +499,7 @@ export class SeedClient<
|
|
506
499
|
}
|
507
500
|
|
508
501
|
async addToList(by: string, subject: string, list: RecordRef) {
|
509
|
-
const res = await this.agent.app.bsky.graph.listitem.create(
|
502
|
+
const res = await this.agent.api.app.bsky.graph.listitem.create(
|
510
503
|
{ repo: by },
|
511
504
|
{ subject, list: list.uriStr, createdAt: new Date().toISOString() },
|
512
505
|
this.getHeaders(by),
|
@@ -524,7 +517,7 @@ export class SeedClient<
|
|
524
517
|
if (!foundList) return
|
525
518
|
const foundItem = foundList.items[subject]
|
526
519
|
if (!foundItem) return
|
527
|
-
await this.agent.app.bsky.graph.listitem.delete(
|
520
|
+
await this.agent.api.app.bsky.graph.listitem.delete(
|
528
521
|
{ repo: by, rkey: foundItem.uri.rkey },
|
529
522
|
this.getHeaders(by),
|
530
523
|
)
|
@@ -538,7 +531,7 @@ export class SeedClient<
|
|
538
531
|
reportedBy: string
|
539
532
|
}) {
|
540
533
|
const { reasonType, subject, reason, reportedBy } = opts
|
541
|
-
const result = await this.agent.com.atproto.moderation.createReport(
|
534
|
+
const result = await this.agent.api.com.atproto.moderation.createReport(
|
542
535
|
{ reasonType, subject, reason },
|
543
536
|
{
|
544
537
|
encoding: 'application/json',
|