From 8d9b1f70cd22ae3562aac8809c15b73646133f78 Mon Sep 17 00:00:00 2001 From: intrnl Date: Sat, 2 Dec 2023 03:28:54 +0700 Subject: [PATCH] Attach record URI to listItemView (#1758) * feat: attach record uri to listitemview * chore: attempt to update test snapshots --- lexicons/app/bsky/graph/defs.json | 3 ++- packages/api/src/client/lexicons.ts | 6 +++++- packages/api/src/client/types/app/bsky/graph/defs.ts | 1 + packages/bsky/src/api/app/bsky/graph/getList.ts | 4 ++-- packages/bsky/src/lexicon/lexicons.ts | 6 +++++- packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts | 1 + packages/bsky/src/services/graph/index.ts | 6 +++++- .../bsky/tests/views/__snapshots__/block-lists.test.ts.snap | 2 ++ .../bsky/tests/views/__snapshots__/mute-lists.test.ts.snap | 2 ++ packages/pds/src/lexicon/lexicons.ts | 6 +++++- packages/pds/src/lexicon/types/app/bsky/graph/defs.ts | 1 + packages/pds/tests/proxied/__snapshots__/views.test.ts.snap | 6 ++++-- 12 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lexicons/app/bsky/graph/defs.json b/lexicons/app/bsky/graph/defs.json index c957f211670..219c4a6de27 100644 --- a/lexicons/app/bsky/graph/defs.json +++ b/lexicons/app/bsky/graph/defs.json @@ -40,8 +40,9 @@ }, "listItemView": { "type": "object", - "required": ["subject"], + "required": ["uri", "subject"], "properties": { + "uri": { "type": "string", "format": "at-uri" }, "subject": { "type": "ref", "ref": "app.bsky.actor.defs#profileView" } } }, diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 25a60f90054..a6377d85a9a 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -6423,8 +6423,12 @@ export const schemaDict = { }, listItemView: { type: 'object', - required: ['subject'], + required: ['uri', 'subject'], properties: { + uri: { + type: 'string', + format: 'at-uri', + }, subject: { type: 'ref', ref: 'lex:app.bsky.actor.defs#profileView', diff --git a/packages/api/src/client/types/app/bsky/graph/defs.ts b/packages/api/src/client/types/app/bsky/graph/defs.ts index 19c2cc81337..0b22401bcdf 100644 --- a/packages/api/src/client/types/app/bsky/graph/defs.ts +++ b/packages/api/src/client/types/app/bsky/graph/defs.ts @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult { } export interface ListItemView { + uri: string subject: AppBskyActorDefs.ProfileView [k: string]: unknown } diff --git a/packages/bsky/src/api/app/bsky/graph/getList.ts b/packages/bsky/src/api/app/bsky/graph/getList.ts index 3c95357d005..82a70848cd9 100644 --- a/packages/bsky/src/api/app/bsky/graph/getList.ts +++ b/packages/bsky/src/api/app/bsky/graph/getList.ts @@ -104,7 +104,7 @@ const presentation = (state: HydrationState, ctx: Context) => { const items = mapDefined(listItems, (item) => { const subject = actors[item.did] if (!subject) return - return { subject } + return { uri: item.uri, subject } }) return { list: listView, items, cursor } } @@ -122,7 +122,7 @@ type Params = QueryParams & { type SkeletonState = { params: Params list: Actor & ListInfo - listItems: (Actor & { cid: string; sortAt: string })[] + listItems: (Actor & { uri: string; cid: string; sortAt: string })[] cursor?: string } diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index 25a60f90054..a6377d85a9a 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -6423,8 +6423,12 @@ export const schemaDict = { }, listItemView: { type: 'object', - required: ['subject'], + required: ['uri', 'subject'], properties: { + uri: { + type: 'string', + format: 'at-uri', + }, subject: { type: 'ref', ref: 'lex:app.bsky.actor.defs#profileView', diff --git a/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts b/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts index f6c7cb7d77d..be2d8c385d9 100644 --- a/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts +++ b/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult { } export interface ListItemView { + uri: string subject: AppBskyActorDefs.ProfileView [k: string]: unknown } diff --git a/packages/bsky/src/services/graph/index.ts b/packages/bsky/src/services/graph/index.ts index 190e3ac0661..b154a8c47bb 100644 --- a/packages/bsky/src/services/graph/index.ts +++ b/packages/bsky/src/services/graph/index.ts @@ -109,7 +109,11 @@ export class GraphService { .selectFrom('list_item') .innerJoin('actor as subject', 'subject.did', 'list_item.subjectDid') .selectAll('subject') - .select(['list_item.cid as cid', 'list_item.sortAt as sortAt']) + .select([ + 'list_item.uri as uri', + 'list_item.cid as cid', + 'list_item.sortAt as sortAt', + ]) } async getBlockAndMuteState( diff --git a/packages/bsky/tests/views/__snapshots__/block-lists.test.ts.snap b/packages/bsky/tests/views/__snapshots__/block-lists.test.ts.snap index 86fe23283c4..1f4f42f2003 100644 --- a/packages/bsky/tests/views/__snapshots__/block-lists.test.ts.snap +++ b/packages/bsky/tests/views/__snapshots__/block-lists.test.ts.snap @@ -489,6 +489,7 @@ Object { "muted": false, }, }, + "uri": "record(4)", }, Object { "subject": Object { @@ -541,6 +542,7 @@ Object { "muted": false, }, }, + "uri": "record(5)", }, ], "list": Object { diff --git a/packages/bsky/tests/views/__snapshots__/mute-lists.test.ts.snap b/packages/bsky/tests/views/__snapshots__/mute-lists.test.ts.snap index 438b48b4fdd..8b88231fe3b 100644 --- a/packages/bsky/tests/views/__snapshots__/mute-lists.test.ts.snap +++ b/packages/bsky/tests/views/__snapshots__/mute-lists.test.ts.snap @@ -518,6 +518,7 @@ Object { }, }, }, + "uri": "record(3)", }, Object { "subject": Object { @@ -545,6 +546,7 @@ Object { }, }, }, + "uri": "record(5)", }, ], "list": Object { diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 25a60f90054..a6377d85a9a 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -6423,8 +6423,12 @@ export const schemaDict = { }, listItemView: { type: 'object', - required: ['subject'], + required: ['uri', 'subject'], properties: { + uri: { + type: 'string', + format: 'at-uri', + }, subject: { type: 'ref', ref: 'lex:app.bsky.actor.defs#profileView', diff --git a/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts b/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts index f6c7cb7d77d..be2d8c385d9 100644 --- a/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts +++ b/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult { } export interface ListItemView { + uri: string subject: AppBskyActorDefs.ProfileView [k: string]: unknown } diff --git a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap index 0dbe9b5498d..5fcc0be8faf 100644 --- a/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap +++ b/packages/pds/tests/proxied/__snapshots__/views.test.ts.snap @@ -3326,6 +3326,7 @@ Object { "muted": false, }, }, + "uri": "record(3)", }, Object { "subject": Object { @@ -3341,7 +3342,7 @@ Object { "cts": "1970-01-01T00:00:00.000Z", "neg": false, "src": "user(3)", - "uri": "record(5)", + "uri": "record(7)", "val": "self-label-a", }, Object { @@ -3349,7 +3350,7 @@ Object { "cts": "1970-01-01T00:00:00.000Z", "neg": false, "src": "user(3)", - "uri": "record(5)", + "uri": "record(7)", "val": "self-label-b", }, ], @@ -3358,6 +3359,7 @@ Object { "muted": false, }, }, + "uri": "record(6)", }, ], "list": Object {