diff --git a/apps/preview-bot/src/ports-http.test.ts b/apps/preview-bot/src/ports-http.test.ts index 5f7a23c..977a60b 100644 --- a/apps/preview-bot/src/ports-http.test.ts +++ b/apps/preview-bot/src/ports-http.test.ts @@ -52,6 +52,25 @@ describe('listRepoRecords', () => { ]) }) + test('falls back to rkey as repository name when value.name is omitted', async () => { + const { fetch } = fakeFetch({ + [`${PDS}/xrpc/com.atproto.repo.listRecords`]: () => + json({ + records: [ + { + uri: `at://${OWNER}/sh.tangled.repo/wisp-preview-test`, + value: { knot: 'knot.example', spindle: 'spindle.example', repoDid: `did:plc:${'r'.repeat(24)}` }, + }, + ], + }), + }) + + const records = await build({ fetch }).listRepoRecords(OWNER) + expect(records).toEqual([ + { rkey: 'wisp-preview-test', name: 'wisp-preview-test', spindle: 'spindle.example', repoDid: `did:plc:${'r'.repeat(24)}` }, + ]) + }) + test('follows the cursor and stops at 500 records', async () => { const requested: string[] = [] const fetch = async (url: string) => { diff --git a/apps/preview-bot/src/ports-http.ts b/apps/preview-bot/src/ports-http.ts index 5de68e2..630d162 100644 --- a/apps/preview-bot/src/ports-http.ts +++ b/apps/preview-bot/src/ports-http.ts @@ -81,9 +81,10 @@ export function createHttpPorts(options: HttpPortsOptions): Ports { for (const item of page.records ?? []) { if (!isObject(item) || !isObject(item.value)) continue const value = item.value + const rkey = typeof item.uri === 'string' ? (item.uri.split('/').pop() ?? '') : '' result.push({ - rkey: typeof item.uri === 'string' ? (item.uri.split('/').pop() ?? '') : '', - name: typeof value.name === 'string' ? value.name : undefined, + rkey, + name: typeof value.name === 'string' ? value.name : rkey, spindle: typeof value.spindle === 'string' ? value.spindle : undefined, repoDid: typeof value.repoDid === 'string' ? value.repoDid : undefined, })