@atproto/dev-env 0.5.15 → 0.5.17

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.
@@ -21,7 +21,7 @@ import {
21
21
  } from '@atproto/api'
22
22
  import { CidString, Client } from '@atproto/lex'
23
23
  import { BlobRef } from '@atproto/lexicon'
24
- import { AtUri, AtUriString, DidString } from '@atproto/syntax'
24
+ import { AtUri, AtUriString, DidString, HandleString } from '@atproto/syntax'
25
25
  import { TestNetworkNoAppView } from '../network-no-appview.js'
26
26
 
27
27
  // Makes it simple to create data via the XRPC client,
@@ -71,18 +71,18 @@ export class SeedClient<
71
71
  Network extends TestNetworkNoAppView = TestNetworkNoAppView,
72
72
  > {
73
73
  accounts: Record<
74
- string,
74
+ DidString,
75
75
  {
76
76
  did: DidString
77
77
  accessJwt: string
78
78
  refreshJwt: string
79
- handle: string
79
+ handle: HandleString
80
80
  email: string
81
81
  password: string
82
82
  }
83
83
  >
84
84
  profiles: Record<
85
- string,
85
+ DidString,
86
86
  {
87
87
  displayName: string
88
88
  description: string
@@ -91,41 +91,53 @@ export class SeedClient<
91
91
  ref: RecordRef
92
92
  }
93
93
  >
94
- follows: Record<string, Record<string, RecordRef>>
95
- blocks: Record<string, Record<string, RecordRef>>
96
- mutes: Record<string, Set<string>>
94
+ follows: Record<DidString, Record<DidString, RecordRef>>
95
+ blocks: Record<DidString, Record<DidString, RecordRef>>
96
+ mutes: Record<DidString, Set<DidString>>
97
97
  posts: Record<
98
- string,
98
+ DidString,
99
99
  { text: string; ref: RecordRef; images: ImageRef[]; quote?: RecordRef }[]
100
100
  >
101
- likes: Record<string, Record<string, AtUri>>
101
+ likes: Record<DidString, Record<string, AtUri>>
102
102
  replies: Record<
103
103
  string,
104
104
  { text: string; ref: RecordRef; images: ImageRef[] }[]
105
105
  >
106
- reposts: Record<string, RecordRef[]>
106
+ reposts: Record<DidString, RecordRef[]>
107
107
  lists: Record<
108
- string,
109
- Record<string, { ref: RecordRef; items: Record<string, RecordRef> }>
108
+ DidString,
109
+ Record<
110
+ AtUriString,
111
+ {
112
+ ref: RecordRef
113
+ items: Record<DidString, RecordRef>
114
+ }
115
+ >
110
116
  >
111
117
  feedgens: Record<
112
- string,
113
- Record<string, { ref: RecordRef; items: Record<string, RecordRef> }>
118
+ DidString,
119
+ Record<
120
+ AtUriString,
121
+ {
122
+ ref: RecordRef
123
+ items: Record<string, RecordRef>
124
+ }
125
+ >
114
126
  >
115
127
  starterpacks: Record<
116
- string,
128
+ DidString,
117
129
  Record<
118
- string,
130
+ AtUriString,
119
131
  {
120
132
  ref: RecordRef
121
133
  name: string
122
134
  list: RecordRef
123
- feeds: string[]
135
+ feeds: readonly AtUriString[]
124
136
  }
125
137
  >
126
138
  >
127
139
 
128
- verifications: Record<string, Record<string, AtUri>>
140
+ verifications: Record<DidString, Record<DidString, AtUri>>
129
141
 
130
142
  dids: Record<string, DidString>
131
143
 
@@ -153,7 +165,7 @@ export class SeedClient<
153
165
  async createAccount(
154
166
  shortName: string,
155
167
  params: {
156
- handle: string
168
+ handle: HandleString
157
169
  email: string
158
170
  password: string
159
171
  inviteCode?: string
@@ -164,7 +176,8 @@ export class SeedClient<
164
176
  const did = account.did as DidString
165
177
  this.dids[shortName] = did
166
178
  this.accounts[account.did] = {
167
- ...account,
179
+ // @NOTE type case needed until we move test to lex-sdk
180
+ ...(account as typeof account & { handle: HandleString }),
168
181
  did,
169
182
  email: params.email,
170
183
  password: params.password,
@@ -172,7 +185,7 @@ export class SeedClient<
172
185
  return this.accounts[account.did]
173
186
  }
174
187
 
175
- async updateHandle(by: string, handle: string) {
188
+ async updateHandle(by: DidString, handle: HandleString) {
176
189
  await this.agent.com.atproto.identity.updateHandle(
177
190
  { handle },
178
191
  { encoding: 'application/json', headers: this.getHeaders(by) },
@@ -180,10 +193,10 @@ export class SeedClient<
180
193
  }
181
194
 
182
195
  async createProfile(
183
- by: string,
196
+ by: DidString,
184
197
  displayName: string,
185
198
  description: string,
186
- selfLabels?: string[],
199
+ selfLabels?: readonly string[],
187
200
  joinedViaStarterPack?: RecordRef,
188
201
  overrides?: Partial<AppBskyActorProfile.Record>,
189
202
  ): Promise<{
@@ -234,7 +247,7 @@ export class SeedClient<
234
247
  return this.profiles[by]
235
248
  }
236
249
 
237
- async updateProfile(by: string, record: Record<string, unknown>) {
250
+ async updateProfile(by: DidString, record: Record<string, unknown>) {
238
251
  const res = await this.agent.com.atproto.repo.putRecord(
239
252
  {
240
253
  repo: by,
@@ -253,8 +266,8 @@ export class SeedClient<
253
266
  }
254
267
 
255
268
  async follow(
256
- from: string,
257
- to: string,
269
+ from: DidString,
270
+ to: DidString,
258
271
  overrides?: Partial<AppBskyGraphFollow.Record>,
259
272
  ) {
260
273
  const res = await this.agent.app.bsky.graph.follow.create(
@@ -271,7 +284,7 @@ export class SeedClient<
271
284
  return this.follows[from][to]
272
285
  }
273
286
 
274
- async unfollow(from: string, to: string) {
287
+ async unfollow(from: DidString, to: DidString) {
275
288
  const follow = this.follows[from][to]
276
289
  if (!follow) {
277
290
  throw new Error('follow does not exist')
@@ -284,8 +297,8 @@ export class SeedClient<
284
297
  }
285
298
 
286
299
  async block(
287
- from: string,
288
- to: string,
300
+ from: DidString,
301
+ to: DidString,
289
302
  overrides?: Partial<AppBskyGraphBlock.Record>,
290
303
  ) {
291
304
  const res = await this.agent.app.bsky.graph.block.create(
@@ -302,7 +315,7 @@ export class SeedClient<
302
315
  return this.blocks[from][to]
303
316
  }
304
317
 
305
- async unblock(from: string, to: string) {
318
+ async unblock(from: DidString, to: DidString) {
306
319
  const block = this.blocks[from][to]
307
320
  if (!block) {
308
321
  throw new Error('block does not exist')
@@ -314,7 +327,7 @@ export class SeedClient<
314
327
  delete this.blocks[from][to]
315
328
  }
316
329
 
317
- async mute(from: string, to: string) {
330
+ async mute(from: DidString, to: DidString) {
318
331
  await this.agent.app.bsky.graph.muteActor(
319
332
  {
320
333
  actor: to,
@@ -327,7 +340,7 @@ export class SeedClient<
327
340
  }
328
341
 
329
342
  async post(
330
- by: string,
343
+ by: DidString,
331
344
  text: string,
332
345
  facets?: AppBskyRichtextFacet.Main[],
333
346
  images?: ImageRef[],
@@ -373,7 +386,7 @@ export class SeedClient<
373
386
  return post
374
387
  }
375
388
 
376
- async deletePost(by: string, uri: AtUri) {
389
+ async deletePost(by: DidString, uri: AtUri) {
377
390
  await this.agent.app.bsky.feed.post.delete(
378
391
  {
379
392
  repo: by,
@@ -384,7 +397,7 @@ export class SeedClient<
384
397
  }
385
398
 
386
399
  async uploadFile(
387
- by: string,
400
+ by: DidString,
388
401
  filePath: string,
389
402
  encoding: string,
390
403
  ): Promise<ImageRef> {
@@ -397,7 +410,7 @@ export class SeedClient<
397
410
  }
398
411
 
399
412
  async like(
400
- by: string,
413
+ by: DidString,
401
414
  subject: RecordRef,
402
415
  overrides?: Partial<AppBskyFeedLike.Record>,
403
416
  ) {
@@ -416,7 +429,7 @@ export class SeedClient<
416
429
  }
417
430
 
418
431
  async reply(
419
- by: string,
432
+ by: DidString,
420
433
  root: RecordRef,
421
434
  parent: RecordRef,
422
435
  text: string,
@@ -456,7 +469,7 @@ export class SeedClient<
456
469
  }
457
470
 
458
471
  async repost(
459
- by: string,
472
+ by: DidString,
460
473
  subject: RecordRef,
461
474
  overrides?: Partial<AppBskyFeedRepost.Record>,
462
475
  ) {
@@ -476,7 +489,7 @@ export class SeedClient<
476
489
  }
477
490
 
478
491
  async createList(
479
- by: string,
492
+ by: DidString,
480
493
  name: string,
481
494
  purpose: 'mod' | 'curate' | 'reference',
482
495
  overrides?: Partial<AppBskyGraphList.Record>,
@@ -505,7 +518,7 @@ export class SeedClient<
505
518
  return ref
506
519
  }
507
520
 
508
- async createFeedGen(by: string, feedDid: string, name: string) {
521
+ async createFeedGen(by: DidString, feedDid: string, name: string) {
509
522
  const res = await this.agent.app.bsky.feed.generator.create(
510
523
  { repo: by },
511
524
  {
@@ -525,10 +538,10 @@ export class SeedClient<
525
538
  }
526
539
 
527
540
  async createStarterPack(
528
- by: string,
541
+ by: DidString,
529
542
  name: string,
530
- actors: string[],
531
- feeds?: string[],
543
+ actors: readonly DidString[],
544
+ feeds?: readonly AtUriString[],
532
545
  ) {
533
546
  const list = await this.createList(by, 'n/a', 'reference')
534
547
  for (const did of actors) {
@@ -555,7 +568,7 @@ export class SeedClient<
555
568
  return ref
556
569
  }
557
570
 
558
- async addToList(by: string, subject: string, list: RecordRef) {
571
+ async addToList(by: DidString, subject: DidString, list: RecordRef) {
559
572
  const res = await this.agent.app.bsky.graph.listitem.create(
560
573
  { repo: by },
561
574
  { subject, list: list.uriStr, createdAt: new Date().toISOString() },
@@ -569,7 +582,7 @@ export class SeedClient<
569
582
  return ref
570
583
  }
571
584
 
572
- async rmFromList(by: string, subject: string, list: RecordRef) {
585
+ async rmFromList(by: DidString, subject: DidString, list: RecordRef) {
573
586
  const foundList = (this.lists[by] ?? {})[list.uriStr] ?? {}
574
587
  if (!foundList) return
575
588
  const foundItem = foundList.items[subject]
@@ -591,7 +604,7 @@ export class SeedClient<
591
604
  | $Typed<ChatBskyConvoDefs.ConvoRef>
592
605
  | { $type: string }
593
606
  reason?: string
594
- reportedBy: string
607
+ reportedBy: DidString
595
608
  }): Promise<
596
609
  ComAtprotoModerationCreateReport.OutputSchema & {
597
610
  subject:
@@ -614,9 +627,9 @@ export class SeedClient<
614
627
  }
615
628
 
616
629
  async verify(
617
- by: string,
618
- subject: string,
619
- handle: string,
630
+ by: DidString,
631
+ subject: DidString,
632
+ handle: HandleString,
620
633
  displayName: string,
621
634
  overrides?: Partial<AppBskyGraphVerification.Record>,
622
635
  ) {
@@ -636,7 +649,7 @@ export class SeedClient<
636
649
  return this.verifications[by][subject]
637
650
  }
638
651
 
639
- async unverify(by: string, subject: string) {
652
+ async unverify(by: DidString, subject: DidString) {
640
653
  const verification = this.verifications[by]?.[subject]
641
654
  if (!verification) {
642
655
  throw new Error('verification does not exist')
@@ -649,7 +662,7 @@ export class SeedClient<
649
662
  delete this.verifications[by][subject]
650
663
  }
651
664
 
652
- getHeaders(did: string) {
665
+ getHeaders(did: DidString) {
653
666
  return SeedClient.getHeaders(this.accounts[did].accessJwt)
654
667
  }
655
668
 
@@ -54,4 +54,4 @@ const users = {
54
54
  handle: 'eve.test',
55
55
  password: 'eve-pass',
56
56
  },
57
- }
57
+ } as const
@@ -1,14 +1,15 @@
1
1
  import { AppBskyFeedPost } from '@atproto/api'
2
2
  import type { DatabaseSchema } from '@atproto/bsky'
3
+ import type { DidString, HandleString } from '@atproto/syntax'
3
4
  import { TestNetworkNoAppView } from '../network-no-appview.js'
4
5
  import { TestNetwork } from '../network.js'
5
6
  import { RecordRef, SeedClient } from './client.js'
6
7
 
7
8
  type User = {
8
9
  id: string
9
- did: string
10
+ did: DidString
10
11
  email: string
11
- handle: string
12
+ handle: HandleString
12
13
  password: string
13
14
  displayName: string
14
15
  description: string
@@ -21,7 +22,7 @@ function createUserStub(name: string): User {
21
22
  // @ts-ignore overwritten during seeding
22
23
  did: undefined,
23
24
  email: `${name}@test.com`,
24
- handle: `${name}.test`,
25
+ handle: `${name}.test` as HandleString,
25
26
  password: `${name}-pass`,
26
27
  displayName: name,
27
28
  description: `hi im ${name} label_me`,
@@ -1,4 +1,5 @@
1
1
  import { chunkArray } from '@atproto/common-web'
2
+ import type { HandleString } from '@atproto/syntax'
2
3
  import { SeedClient } from './client.js'
3
4
 
4
5
  export default async function usersBulkSeed(sc: SeedClient, max = Infinity) {
@@ -11,7 +12,7 @@ export default async function usersBulkSeed(sc: SeedClient, max = Infinity) {
11
12
  chunk.map(async (user) => {
12
13
  const { handle, displayName } = user
13
14
  await sc.createAccount(handle, {
14
- handle: handle,
15
+ handle,
15
16
  password: 'password',
16
17
  email: `${handle}@bsky.app`,
17
18
  })
@@ -24,7 +25,7 @@ export default async function usersBulkSeed(sc: SeedClient, max = Infinity) {
24
25
  return sc
25
26
  }
26
27
 
27
- const users = [
28
+ const users: { handle: HandleString; displayName: string | null }[] = [
28
29
  { handle: 'silas77.test', displayName: 'Tanya Denesik' },
29
30
  { handle: 'nicolas-krajcik10.test', displayName: null },
30
31
  { handle: 'lennie-strosin.test', displayName: null },
package/src/seed/users.ts CHANGED
@@ -61,4 +61,4 @@ const users = {
61
61
  description: undefined,
62
62
  selfLabels: undefined,
63
63
  },
64
- }
64
+ } as const
@@ -226,7 +226,7 @@ const users = {
226
226
  handle: 'handleempty.test',
227
227
  password: 'handleempty-pass',
228
228
  },
229
- }
229
+ } as const
230
230
 
231
231
  const createLabel = async (
232
232
  sc: SeedClient<TestNetwork>,