@atproto/bsky 0.0.83 → 0.0.85
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 +26 -0
- package/dist/api/app/bsky/feed/getAuthorFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getAuthorFeed.js +25 -7
- package/dist/api/app/bsky/feed/getAuthorFeed.js.map +1 -1
- package/dist/api/app/bsky/graph/getSuggestedFollowsByActor.js +3 -1
- package/dist/api/app/bsky/graph/getSuggestedFollowsByActor.js.map +1 -1
- package/dist/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.d.ts +4 -0
- package/dist/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.d.ts.map +1 -0
- package/dist/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.js +20 -0
- package/dist/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.js.map +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
- package/dist/data-plane/server/db/migrations/index.js +2 -1
- package/dist/data-plane/server/db/migrations/index.js.map +1 -1
- package/dist/data-plane/server/db/tables/profile.d.ts +2 -0
- package/dist/data-plane/server/db/tables/profile.d.ts.map +1 -1
- package/dist/hydration/feed.d.ts +5 -0
- package/dist/hydration/feed.d.ts.map +1 -1
- package/dist/hydration/feed.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +36 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +47 -3
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +2 -0
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +13 -2
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/defs.js +21 -1
- package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/getAuthorFeed.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/feed/getAuthorFeed.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.d.ts +2 -0
- package/dist/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.d.ts +2 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/repo/getRecord.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/repo/getRecord.d.ts.map +1 -1
- package/dist/views/index.d.ts +4 -0
- package/dist/views/index.d.ts.map +1 -1
- package/dist/views/index.js +22 -1
- package/dist/views/index.js.map +1 -1
- package/package.json +13 -13
- package/src/api/app/bsky/feed/getAuthorFeed.ts +32 -7
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +4 -1
- package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +17 -0
- package/src/data-plane/server/db/migrations/index.ts +1 -0
- package/src/data-plane/server/db/tables/profile.ts +2 -0
- package/src/hydration/feed.ts +9 -1
- package/src/lexicon/lexicons.ts +49 -3
- package/src/lexicon/types/app/bsky/actor/defs.ts +2 -0
- package/src/lexicon/types/app/bsky/actor/profile.ts +1 -0
- package/src/lexicon/types/app/bsky/feed/defs.ts +38 -2
- package/src/lexicon/types/app/bsky/feed/getAuthorFeed.ts +1 -0
- package/src/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.ts +2 -0
- package/src/lexicon/types/app/bsky/unspecced/getSuggestionsSkeleton.ts +2 -0
- package/src/lexicon/types/com/atproto/repo/getRecord.ts +1 -0
- package/src/views/index.ts +22 -2
- package/tests/views/__snapshots__/author-feed.test.ts.snap +2462 -0
- package/tests/views/author-feed.test.ts +176 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AtpAgent } from '@atproto/api'
|
|
1
|
+
import { AtpAgent, AppBskyActorProfile, AppBskyFeedDefs } from '@atproto/api'
|
|
2
2
|
import { TestNetwork, SeedClient, authorFeedSeed } from '@atproto/dev-env'
|
|
3
3
|
import {
|
|
4
4
|
forSnapshot,
|
|
@@ -16,6 +16,7 @@ import { ids } from '../../src/lexicon/lexicons'
|
|
|
16
16
|
describe('pds author feed views', () => {
|
|
17
17
|
let network: TestNetwork
|
|
18
18
|
let agent: AtpAgent
|
|
19
|
+
let pdsAgent: AtpAgent
|
|
19
20
|
let sc: SeedClient
|
|
20
21
|
|
|
21
22
|
// account dids, for convenience
|
|
@@ -30,6 +31,7 @@ describe('pds author feed views', () => {
|
|
|
30
31
|
dbPostgresSchema: 'bsky_views_author_feed',
|
|
31
32
|
})
|
|
32
33
|
agent = network.bsky.getClient()
|
|
34
|
+
pdsAgent = network.pds.getClient()
|
|
33
35
|
sc = network.getSeedClient()
|
|
34
36
|
await authorFeedSeed(sc)
|
|
35
37
|
await network.processAll()
|
|
@@ -386,6 +388,179 @@ describe('pds author feed views', () => {
|
|
|
386
388
|
}),
|
|
387
389
|
).toBeTruthy()
|
|
388
390
|
})
|
|
391
|
+
|
|
392
|
+
describe('pins', () => {
|
|
393
|
+
async function createAndPinPost() {
|
|
394
|
+
const post = await sc.post(alice, 'pinned post')
|
|
395
|
+
await network.processAll()
|
|
396
|
+
|
|
397
|
+
const profile = await pdsAgent.com.atproto.repo.getRecord({
|
|
398
|
+
repo: alice,
|
|
399
|
+
collection: 'app.bsky.actor.profile',
|
|
400
|
+
rkey: 'self',
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
if (!AppBskyActorProfile.isRecord(profile.data.value)) {
|
|
404
|
+
throw new Error('')
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const newProfile: AppBskyActorProfile.Record = {
|
|
408
|
+
...profile,
|
|
409
|
+
pinnedPost: {
|
|
410
|
+
uri: post.ref.uriStr,
|
|
411
|
+
cid: post.ref.cid.toString(),
|
|
412
|
+
},
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
await sc.updateProfile(alice, newProfile)
|
|
416
|
+
|
|
417
|
+
await network.processAll()
|
|
418
|
+
|
|
419
|
+
return post
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
it('params.includePins = true, pin is in first page of results', async () => {
|
|
423
|
+
await sc.post(alice, 'not pinned post')
|
|
424
|
+
const post = await createAndPinPost()
|
|
425
|
+
await sc.post(alice, 'not pinned post')
|
|
426
|
+
|
|
427
|
+
const { data } = await agent.api.app.bsky.feed.getAuthorFeed(
|
|
428
|
+
{ actor: sc.accounts[alice].handle, includePins: true },
|
|
429
|
+
{
|
|
430
|
+
headers: await network.serviceHeaders(
|
|
431
|
+
alice,
|
|
432
|
+
ids.AppBskyFeedGetAuthorFeed,
|
|
433
|
+
),
|
|
434
|
+
},
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
const pinnedPosts = data.feed.filter(
|
|
438
|
+
(item) => item.post.uri === post.ref.uriStr,
|
|
439
|
+
)
|
|
440
|
+
expect(pinnedPosts.length).toEqual(1)
|
|
441
|
+
|
|
442
|
+
const pinnedPost = data.feed.at(0)
|
|
443
|
+
expect(pinnedPost?.post?.uri).toEqual(post.ref.uriStr)
|
|
444
|
+
expect(pinnedPost?.post?.viewer?.pinned).toBeTruthy()
|
|
445
|
+
expect(AppBskyFeedDefs.isReasonPin(pinnedPost?.reason)).toBeTruthy()
|
|
446
|
+
|
|
447
|
+
const notPinnedPost = data.feed.at(1)
|
|
448
|
+
expect(notPinnedPost?.post?.viewer?.pinned).toBeFalsy()
|
|
449
|
+
expect(forSnapshot(data.feed)).toMatchSnapshot()
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
it('params.includePins = true, pin is NOT in first page of results', async () => {
|
|
453
|
+
const post = await createAndPinPost()
|
|
454
|
+
await sc.post(alice, 'not pinned post')
|
|
455
|
+
await sc.post(alice, 'not pinned post')
|
|
456
|
+
await network.processAll()
|
|
457
|
+
const { data: page1 } = await agent.api.app.bsky.feed.getAuthorFeed(
|
|
458
|
+
{ actor: sc.accounts[alice].handle, includePins: true, limit: 2 },
|
|
459
|
+
{
|
|
460
|
+
headers: await network.serviceHeaders(
|
|
461
|
+
alice,
|
|
462
|
+
ids.AppBskyFeedGetAuthorFeed,
|
|
463
|
+
),
|
|
464
|
+
},
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
// exists with `reason`
|
|
468
|
+
const pinnedPost = page1.feed.find(
|
|
469
|
+
(item) => item.post.uri === post.ref.uriStr,
|
|
470
|
+
)
|
|
471
|
+
expect(pinnedPost?.post?.uri).toEqual(post.ref.uriStr)
|
|
472
|
+
expect(pinnedPost?.post?.viewer?.pinned).toBeTruthy()
|
|
473
|
+
expect(AppBskyFeedDefs.isReasonPin(pinnedPost?.reason)).toBeTruthy()
|
|
474
|
+
expect(forSnapshot(page1.feed)).toMatchSnapshot()
|
|
475
|
+
|
|
476
|
+
const { data: page2 } = await agent.api.app.bsky.feed.getAuthorFeed(
|
|
477
|
+
{
|
|
478
|
+
actor: sc.accounts[alice].handle,
|
|
479
|
+
includePins: true,
|
|
480
|
+
cursor: page1.cursor,
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
headers: await network.serviceHeaders(
|
|
484
|
+
alice,
|
|
485
|
+
ids.AppBskyFeedGetAuthorFeed,
|
|
486
|
+
),
|
|
487
|
+
},
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
// exists without `reason`
|
|
491
|
+
const laterPinnedPost = page2.feed.find(
|
|
492
|
+
(item) => item.post.uri === post.ref.uriStr,
|
|
493
|
+
)
|
|
494
|
+
expect(laterPinnedPost?.post?.uri).toEqual(post.ref.uriStr)
|
|
495
|
+
expect(laterPinnedPost?.post?.viewer?.pinned).toBeTruthy()
|
|
496
|
+
expect(AppBskyFeedDefs.isReasonPin(laterPinnedPost?.reason)).toBeFalsy()
|
|
497
|
+
expect(forSnapshot(page2.feed)).toMatchSnapshot()
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
it('params.includePins = false', async () => {
|
|
501
|
+
const post = await createAndPinPost()
|
|
502
|
+
const { data } = await agent.api.app.bsky.feed.getAuthorFeed(
|
|
503
|
+
{ actor: sc.accounts[alice].handle },
|
|
504
|
+
{
|
|
505
|
+
headers: await network.serviceHeaders(
|
|
506
|
+
alice,
|
|
507
|
+
ids.AppBskyFeedGetAuthorFeed,
|
|
508
|
+
),
|
|
509
|
+
},
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
// exists without `reason`
|
|
513
|
+
const pinnedPost = data.feed.find(
|
|
514
|
+
(item) => item.post.uri === post.ref.uriStr,
|
|
515
|
+
)
|
|
516
|
+
expect(AppBskyFeedDefs.isReasonPin(pinnedPost?.reason)).toBeFalsy()
|
|
517
|
+
expect(forSnapshot(data.feed)).toMatchSnapshot()
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
it("cannot pin someone else's post", async () => {
|
|
521
|
+
const bobPost = await sc.post(bob, 'pinned post')
|
|
522
|
+
await sc.post(alice, 'not pinned post')
|
|
523
|
+
await network.processAll()
|
|
524
|
+
|
|
525
|
+
const profile = await pdsAgent.com.atproto.repo.getRecord({
|
|
526
|
+
repo: alice,
|
|
527
|
+
collection: 'app.bsky.actor.profile',
|
|
528
|
+
rkey: 'self',
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
if (!AppBskyActorProfile.isRecord(profile.data.value)) {
|
|
532
|
+
throw new Error('')
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const newProfile: AppBskyActorProfile.Record = {
|
|
536
|
+
...profile,
|
|
537
|
+
pinnedPost: {
|
|
538
|
+
uri: bobPost.ref.uriStr,
|
|
539
|
+
cid: bobPost.ref.cid.toString(),
|
|
540
|
+
},
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
await sc.updateProfile(alice, newProfile)
|
|
544
|
+
|
|
545
|
+
await network.processAll()
|
|
546
|
+
|
|
547
|
+
const { data } = await agent.api.app.bsky.feed.getAuthorFeed(
|
|
548
|
+
{ actor: sc.accounts[alice].handle },
|
|
549
|
+
{
|
|
550
|
+
headers: await network.serviceHeaders(
|
|
551
|
+
alice,
|
|
552
|
+
ids.AppBskyFeedGetAuthorFeed,
|
|
553
|
+
),
|
|
554
|
+
},
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
const pinnedPost = data.feed.find(
|
|
558
|
+
(item) => item.post.uri === bobPost.ref.uriStr,
|
|
559
|
+
)
|
|
560
|
+
expect(pinnedPost).toBeUndefined()
|
|
561
|
+
expect(forSnapshot(data.feed)).toMatchSnapshot()
|
|
562
|
+
})
|
|
563
|
+
})
|
|
389
564
|
})
|
|
390
565
|
|
|
391
566
|
function isReplyTo(reply: ReplyRef, did: string) {
|