@atproto/bsky 0.0.97 → 0.0.99

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/api/app/bsky/actor/getProfiles.d.ts.map +1 -1
  3. package/dist/api/app/bsky/actor/getProfiles.js +6 -2
  4. package/dist/api/app/bsky/actor/getProfiles.js.map +1 -1
  5. package/dist/api/app/bsky/notification/listNotifications.js +45 -3
  6. package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
  7. package/dist/api/app/bsky/unspecced/getConfig.d.ts.map +1 -1
  8. package/dist/api/app/bsky/unspecced/getConfig.js +1 -0
  9. package/dist/api/app/bsky/unspecced/getConfig.js.map +1 -1
  10. package/dist/api/app/bsky/unspecced/getTrendingTopics.d.ts +4 -0
  11. package/dist/api/app/bsky/unspecced/getTrendingTopics.d.ts.map +1 -0
  12. package/dist/api/app/bsky/unspecced/getTrendingTopics.js +51 -0
  13. package/dist/api/app/bsky/unspecced/getTrendingTopics.js.map +1 -0
  14. package/dist/api/index.d.ts.map +1 -1
  15. package/dist/api/index.js +2 -0
  16. package/dist/api/index.js.map +1 -1
  17. package/dist/config.d.ts +6 -0
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +15 -0
  20. package/dist/config.js.map +1 -1
  21. package/dist/context.d.ts +2 -0
  22. package/dist/context.d.ts.map +1 -1
  23. package/dist/context.js +3 -0
  24. package/dist/context.js.map +1 -1
  25. package/dist/hydration/actor.d.ts.map +1 -1
  26. package/dist/hydration/actor.js +6 -6
  27. package/dist/hydration/actor.js.map +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +7 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/lexicon/index.d.ts +2 -0
  32. package/dist/lexicon/index.d.ts.map +1 -1
  33. package/dist/lexicon/index.js +4 -0
  34. package/dist/lexicon/index.js.map +1 -1
  35. package/dist/lexicon/lexicons.d.ts +150 -0
  36. package/dist/lexicon/lexicons.d.ts.map +1 -1
  37. package/dist/lexicon/lexicons.js +76 -0
  38. package/dist/lexicon/lexicons.js.map +1 -1
  39. package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts +2 -0
  40. package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts.map +1 -1
  41. package/dist/lexicon/types/app/bsky/notification/listNotifications.js.map +1 -1
  42. package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts +9 -0
  43. package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts.map +1 -1
  44. package/dist/lexicon/types/app/bsky/unspecced/defs.js +10 -0
  45. package/dist/lexicon/types/app/bsky/unspecced/defs.js.map +1 -1
  46. package/dist/lexicon/types/app/bsky/unspecced/getTrendingTopics.d.ts +39 -0
  47. package/dist/lexicon/types/app/bsky/unspecced/getTrendingTopics.d.ts.map +1 -0
  48. package/dist/lexicon/types/app/bsky/unspecced/getTrendingTopics.js +3 -0
  49. package/dist/lexicon/types/app/bsky/unspecced/getTrendingTopics.js.map +1 -0
  50. package/package.json +11 -11
  51. package/src/api/app/bsky/actor/getProfiles.ts +6 -2
  52. package/src/api/app/bsky/notification/listNotifications.ts +57 -3
  53. package/src/api/app/bsky/unspecced/getConfig.ts +1 -0
  54. package/src/api/app/bsky/unspecced/getTrendingTopics.ts +97 -0
  55. package/src/api/index.ts +2 -0
  56. package/src/config.ts +21 -0
  57. package/src/context.ts +5 -0
  58. package/src/hydration/actor.ts +9 -9
  59. package/src/index.ts +11 -0
  60. package/src/lexicon/index.ts +12 -0
  61. package/src/lexicon/lexicons.ts +78 -0
  62. package/src/lexicon/types/app/bsky/notification/listNotifications.ts +2 -0
  63. package/src/lexicon/types/app/bsky/unspecced/defs.ts +20 -0
  64. package/src/lexicon/types/app/bsky/unspecced/getTrendingTopics.ts +49 -0
  65. package/tests/views/__snapshots__/notifications.test.ts.snap +257 -0
  66. package/tests/views/notifications.test.ts +78 -0
  67. package/tsconfig.build.tsbuildinfo +1 -1
@@ -8944,6 +8944,15 @@ export const schemaDict = {
8944
8944
  parameters: {
8945
8945
  type: 'params',
8946
8946
  properties: {
8947
+ reasons: {
8948
+ description: 'Notification reasons to include in response.',
8949
+ type: 'array',
8950
+ items: {
8951
+ type: 'string',
8952
+ description:
8953
+ 'A reason that matches the reason property of #notification.',
8954
+ },
8955
+ },
8947
8956
  limit: {
8948
8957
  type: 'integer',
8949
8958
  minimum: 1,
@@ -9248,6 +9257,24 @@ export const schemaDict = {
9248
9257
  },
9249
9258
  },
9250
9259
  },
9260
+ trendingTopic: {
9261
+ type: 'object',
9262
+ required: ['topic', 'link'],
9263
+ properties: {
9264
+ topic: {
9265
+ type: 'string',
9266
+ },
9267
+ displayName: {
9268
+ type: 'string',
9269
+ },
9270
+ description: {
9271
+ type: 'string',
9272
+ },
9273
+ link: {
9274
+ type: 'string',
9275
+ },
9276
+ },
9277
+ },
9251
9278
  },
9252
9279
  },
9253
9280
  AppBskyUnspeccedGetConfig: {
@@ -9428,6 +9455,56 @@ export const schemaDict = {
9428
9455
  },
9429
9456
  },
9430
9457
  },
9458
+ AppBskyUnspeccedGetTrendingTopics: {
9459
+ lexicon: 1,
9460
+ id: 'app.bsky.unspecced.getTrendingTopics',
9461
+ defs: {
9462
+ main: {
9463
+ type: 'query',
9464
+ description: 'Get a list of trending topics',
9465
+ parameters: {
9466
+ type: 'params',
9467
+ properties: {
9468
+ viewer: {
9469
+ type: 'string',
9470
+ format: 'did',
9471
+ description:
9472
+ 'DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking.',
9473
+ },
9474
+ limit: {
9475
+ type: 'integer',
9476
+ minimum: 1,
9477
+ maximum: 25,
9478
+ default: 10,
9479
+ },
9480
+ },
9481
+ },
9482
+ output: {
9483
+ encoding: 'application/json',
9484
+ schema: {
9485
+ type: 'object',
9486
+ required: ['topics', 'suggested'],
9487
+ properties: {
9488
+ topics: {
9489
+ type: 'array',
9490
+ items: {
9491
+ type: 'ref',
9492
+ ref: 'lex:app.bsky.unspecced.defs#trendingTopic',
9493
+ },
9494
+ },
9495
+ suggested: {
9496
+ type: 'array',
9497
+ items: {
9498
+ type: 'ref',
9499
+ ref: 'lex:app.bsky.unspecced.defs#trendingTopic',
9500
+ },
9501
+ },
9502
+ },
9503
+ },
9504
+ },
9505
+ },
9506
+ },
9507
+ },
9431
9508
  AppBskyUnspeccedSearchActorsSkeleton: {
9432
9509
  lexicon: 1,
9433
9510
  id: 'app.bsky.unspecced.searchActorsSkeleton',
@@ -10911,6 +10988,7 @@ export const ids = {
10911
10988
  'app.bsky.unspecced.getSuggestionsSkeleton',
10912
10989
  AppBskyUnspeccedGetTaggedSuggestions:
10913
10990
  'app.bsky.unspecced.getTaggedSuggestions',
10991
+ AppBskyUnspeccedGetTrendingTopics: 'app.bsky.unspecced.getTrendingTopics',
10914
10992
  AppBskyUnspeccedSearchActorsSkeleton:
10915
10993
  'app.bsky.unspecced.searchActorsSkeleton',
10916
10994
  AppBskyUnspeccedSearchPostsSkeleton: 'app.bsky.unspecced.searchPostsSkeleton',
@@ -11,6 +11,8 @@ import * as AppBskyActorDefs from '../actor/defs'
11
11
  import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
12
12
 
13
13
  export interface QueryParams {
14
+ /** Notification reasons to include in response. */
15
+ reasons?: string[]
14
16
  limit: number
15
17
  priority?: boolean
16
18
  cursor?: string
@@ -63,3 +63,23 @@ export function validateSkeletonSearchStarterPack(
63
63
  v,
64
64
  )
65
65
  }
66
+
67
+ export interface TrendingTopic {
68
+ topic: string
69
+ displayName?: string
70
+ description?: string
71
+ link: string
72
+ [k: string]: unknown
73
+ }
74
+
75
+ export function isTrendingTopic(v: unknown): v is TrendingTopic {
76
+ return (
77
+ isObj(v) &&
78
+ hasProp(v, '$type') &&
79
+ v.$type === 'app.bsky.unspecced.defs#trendingTopic'
80
+ )
81
+ }
82
+
83
+ export function validateTrendingTopic(v: unknown): ValidationResult {
84
+ return lexicons.validate('app.bsky.unspecced.defs#trendingTopic', v)
85
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import express from 'express'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { lexicons } from '../../../../lexicons'
7
+ import { isObj, hasProp } from '../../../../util'
8
+ import { CID } from 'multiformats/cid'
9
+ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as AppBskyUnspeccedDefs from './defs'
11
+
12
+ export interface QueryParams {
13
+ /** DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking. */
14
+ viewer?: string
15
+ limit: number
16
+ }
17
+
18
+ export type InputSchema = undefined
19
+
20
+ export interface OutputSchema {
21
+ topics: AppBskyUnspeccedDefs.TrendingTopic[]
22
+ suggested: AppBskyUnspeccedDefs.TrendingTopic[]
23
+ [k: string]: unknown
24
+ }
25
+
26
+ export type HandlerInput = undefined
27
+
28
+ export interface HandlerSuccess {
29
+ encoding: 'application/json'
30
+ body: OutputSchema
31
+ headers?: { [key: string]: string }
32
+ }
33
+
34
+ export interface HandlerError {
35
+ status: number
36
+ message?: string
37
+ }
38
+
39
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
40
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
41
+ auth: HA
42
+ params: QueryParams
43
+ input: HandlerInput
44
+ req: express.Request
45
+ res: express.Response
46
+ }
47
+ export type Handler<HA extends HandlerAuth = never> = (
48
+ ctx: HandlerReqCtx<HA>,
49
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -1263,6 +1263,263 @@ Array [
1263
1263
  ]
1264
1264
  `;
1265
1265
 
1266
+ exports[`notification views filters notifications by multiple reasons 1`] = `
1267
+ Object {
1268
+ "notifications": Array [
1269
+ Object {
1270
+ "author": Object {
1271
+ "did": "user(0)",
1272
+ "handle": "carol.test",
1273
+ "labels": Array [],
1274
+ "viewer": Object {
1275
+ "blockedBy": false,
1276
+ "followedBy": "record(2)",
1277
+ "following": "record(1)",
1278
+ "muted": false,
1279
+ },
1280
+ },
1281
+ "cid": "cids(0)",
1282
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1283
+ "isRead": false,
1284
+ "labels": Array [],
1285
+ "reason": "reply",
1286
+ "reasonSubject": "record(3)",
1287
+ "record": Object {
1288
+ "$type": "app.bsky.feed.post",
1289
+ "createdAt": "1970-01-01T00:00:00.000Z",
1290
+ "reply": Object {
1291
+ "parent": Object {
1292
+ "cid": "cids(2)",
1293
+ "uri": "record(3)",
1294
+ },
1295
+ "root": Object {
1296
+ "cid": "cids(1)",
1297
+ "uri": "record(4)",
1298
+ },
1299
+ },
1300
+ "text": "indeed",
1301
+ },
1302
+ "uri": "record(0)",
1303
+ },
1304
+ Object {
1305
+ "author": Object {
1306
+ "did": "user(0)",
1307
+ "handle": "carol.test",
1308
+ "labels": Array [],
1309
+ "viewer": Object {
1310
+ "blockedBy": false,
1311
+ "followedBy": "record(2)",
1312
+ "following": "record(1)",
1313
+ "muted": false,
1314
+ },
1315
+ },
1316
+ "cid": "cids(3)",
1317
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1318
+ "isRead": false,
1319
+ "labels": Array [],
1320
+ "reason": "reply",
1321
+ "reasonSubject": "record(4)",
1322
+ "record": Object {
1323
+ "$type": "app.bsky.feed.post",
1324
+ "createdAt": "1970-01-01T00:00:00.000Z",
1325
+ "reply": Object {
1326
+ "parent": Object {
1327
+ "cid": "cids(1)",
1328
+ "uri": "record(4)",
1329
+ },
1330
+ "root": Object {
1331
+ "cid": "cids(1)",
1332
+ "uri": "record(4)",
1333
+ },
1334
+ },
1335
+ "text": "of course",
1336
+ },
1337
+ "uri": "record(5)",
1338
+ },
1339
+ Object {
1340
+ "author": Object {
1341
+ "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(5)@jpeg",
1342
+ "createdAt": "1970-01-01T00:00:00.000Z",
1343
+ "description": "hi im bob label_me",
1344
+ "did": "user(1)",
1345
+ "displayName": "bobby",
1346
+ "handle": "bob.test",
1347
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1348
+ "labels": Array [],
1349
+ "viewer": Object {
1350
+ "blockedBy": false,
1351
+ "followedBy": "record(8)",
1352
+ "following": "record(7)",
1353
+ "muted": false,
1354
+ },
1355
+ },
1356
+ "cid": "cids(4)",
1357
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1358
+ "isRead": false,
1359
+ "labels": Array [
1360
+ Object {
1361
+ "cid": "cids(4)",
1362
+ "cts": "1970-01-01T00:00:00.000Z",
1363
+ "src": "did:example:labeler",
1364
+ "uri": "record(6)",
1365
+ "val": "test-label",
1366
+ },
1367
+ Object {
1368
+ "cid": "cids(4)",
1369
+ "cts": "1970-01-01T00:00:00.000Z",
1370
+ "src": "did:example:labeler",
1371
+ "uri": "record(6)",
1372
+ "val": "test-label-2",
1373
+ },
1374
+ ],
1375
+ "reason": "reply",
1376
+ "reasonSubject": "record(4)",
1377
+ "record": Object {
1378
+ "$type": "app.bsky.feed.post",
1379
+ "createdAt": "1970-01-01T00:00:00.000Z",
1380
+ "embed": Object {
1381
+ "$type": "app.bsky.embed.images",
1382
+ "images": Array [
1383
+ Object {
1384
+ "alt": "../dev-env/src/seed/img/key-landscape-small.jpg",
1385
+ "image": Object {
1386
+ "$type": "blob",
1387
+ "mimeType": "image/jpeg",
1388
+ "ref": Object {
1389
+ "$link": "cids(6)",
1390
+ },
1391
+ "size": 4114,
1392
+ },
1393
+ },
1394
+ ],
1395
+ },
1396
+ "reply": Object {
1397
+ "parent": Object {
1398
+ "cid": "cids(1)",
1399
+ "uri": "record(4)",
1400
+ },
1401
+ "root": Object {
1402
+ "cid": "cids(1)",
1403
+ "uri": "record(4)",
1404
+ },
1405
+ },
1406
+ "text": "hear that label_me label_me_2",
1407
+ },
1408
+ "uri": "record(6)",
1409
+ },
1410
+ Object {
1411
+ "author": Object {
1412
+ "associated": Object {
1413
+ "chat": Object {
1414
+ "allowIncoming": "none",
1415
+ },
1416
+ },
1417
+ "did": "user(3)",
1418
+ "handle": "dan.test",
1419
+ "labels": Array [],
1420
+ "viewer": Object {
1421
+ "blockedBy": false,
1422
+ "following": "record(10)",
1423
+ "muted": false,
1424
+ },
1425
+ },
1426
+ "cid": "cids(7)",
1427
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1428
+ "isRead": false,
1429
+ "labels": Array [],
1430
+ "reason": "mention",
1431
+ "record": Object {
1432
+ "$type": "app.bsky.feed.post",
1433
+ "createdAt": "1970-01-01T00:00:00.000Z",
1434
+ "embed": Object {
1435
+ "$type": "app.bsky.embed.record",
1436
+ "record": Object {
1437
+ "cid": "cids(8)",
1438
+ "uri": "record(11)",
1439
+ },
1440
+ },
1441
+ "facets": Array [
1442
+ Object {
1443
+ "features": Array [
1444
+ Object {
1445
+ "$type": "app.bsky.richtext.facet#mention",
1446
+ "did": "user(4)",
1447
+ },
1448
+ ],
1449
+ "index": Object {
1450
+ "byteEnd": 18,
1451
+ "byteStart": 0,
1452
+ },
1453
+ },
1454
+ ],
1455
+ "text": "@alice.bluesky.xyz is the best",
1456
+ },
1457
+ "uri": "record(9)",
1458
+ },
1459
+ ],
1460
+ "priority": false,
1461
+ "seenAt": "1970-01-01T00:00:00.000Z",
1462
+ }
1463
+ `;
1464
+
1465
+ exports[`notification views filters notifications by reason 1`] = `
1466
+ Object {
1467
+ "notifications": Array [
1468
+ Object {
1469
+ "author": Object {
1470
+ "associated": Object {
1471
+ "chat": Object {
1472
+ "allowIncoming": "none",
1473
+ },
1474
+ },
1475
+ "did": "user(0)",
1476
+ "handle": "dan.test",
1477
+ "labels": Array [],
1478
+ "viewer": Object {
1479
+ "blockedBy": false,
1480
+ "following": "record(1)",
1481
+ "muted": false,
1482
+ },
1483
+ },
1484
+ "cid": "cids(0)",
1485
+ "indexedAt": "1970-01-01T00:00:00.000Z",
1486
+ "isRead": false,
1487
+ "labels": Array [],
1488
+ "reason": "mention",
1489
+ "record": Object {
1490
+ "$type": "app.bsky.feed.post",
1491
+ "createdAt": "1970-01-01T00:00:00.000Z",
1492
+ "embed": Object {
1493
+ "$type": "app.bsky.embed.record",
1494
+ "record": Object {
1495
+ "cid": "cids(1)",
1496
+ "uri": "record(2)",
1497
+ },
1498
+ },
1499
+ "facets": Array [
1500
+ Object {
1501
+ "features": Array [
1502
+ Object {
1503
+ "$type": "app.bsky.richtext.facet#mention",
1504
+ "did": "user(1)",
1505
+ },
1506
+ ],
1507
+ "index": Object {
1508
+ "byteEnd": 18,
1509
+ "byteStart": 0,
1510
+ },
1511
+ },
1512
+ ],
1513
+ "text": "@alice.bluesky.xyz is the best",
1514
+ },
1515
+ "uri": "record(0)",
1516
+ },
1517
+ ],
1518
+ "priority": false,
1519
+ "seenAt": "1970-01-01T00:00:00.000Z",
1520
+ }
1521
+ `;
1522
+
1266
1523
  exports[`notification views generates notifications for quotes 1`] = `
1267
1524
  Array [
1268
1525
  Object {
@@ -417,6 +417,84 @@ describe('notification views', () => {
417
417
  ),
418
418
  ).toBe(true)
419
419
  expect(forSnapshot(notifs.data)).toMatchSnapshot()
420
+ await agent.api.app.bsky.notification.putPreferences(
421
+ { priority: false },
422
+ {
423
+ encoding: 'application/json',
424
+ headers: await network.serviceHeaders(
425
+ sc.dids.carol,
426
+ ids.AppBskyNotificationPutPreferences,
427
+ ),
428
+ },
429
+ )
430
+ await network.processAll()
431
+ })
432
+
433
+ it('filters notifications by reason', async () => {
434
+ const res = await agent.app.bsky.notification.listNotifications(
435
+ {
436
+ reasons: ['mention'],
437
+ },
438
+ {
439
+ headers: await network.serviceHeaders(
440
+ sc.dids.alice,
441
+ ids.AppBskyNotificationListNotifications,
442
+ ),
443
+ },
444
+ )
445
+ expect(res.data.notifications.length).toBe(1)
446
+ expect(forSnapshot(res.data)).toMatchSnapshot()
447
+ })
448
+
449
+ it('filters notifications by multiple reasons', async () => {
450
+ const res = await agent.app.bsky.notification.listNotifications(
451
+ {
452
+ reasons: ['mention', 'reply'],
453
+ },
454
+ {
455
+ headers: await network.serviceHeaders(
456
+ sc.dids.alice,
457
+ ids.AppBskyNotificationListNotifications,
458
+ ),
459
+ },
460
+ )
461
+ expect(res.data.notifications.length).toBe(4)
462
+ expect(forSnapshot(res.data)).toMatchSnapshot()
463
+ })
464
+
465
+ it('paginates filtered notifications', async () => {
466
+ const results = (results) =>
467
+ sort(results.flatMap((res) => res.notifications))
468
+ const paginator = async (cursor?: string) => {
469
+ const res = await agent.app.bsky.notification.listNotifications(
470
+ { reasons: ['mention', 'reply'], cursor, limit: 2 },
471
+ {
472
+ headers: await network.serviceHeaders(
473
+ alice,
474
+ ids.AppBskyNotificationListNotifications,
475
+ ),
476
+ },
477
+ )
478
+ return res.data
479
+ }
480
+
481
+ const paginatedAll = await paginateAll(paginator)
482
+ paginatedAll.forEach((res) =>
483
+ expect(res.notifications.length).toBeLessThanOrEqual(2),
484
+ )
485
+
486
+ const full = await agent.app.bsky.notification.listNotifications(
487
+ { reasons: ['mention', 'reply'] },
488
+ {
489
+ headers: await network.serviceHeaders(
490
+ alice,
491
+ ids.AppBskyNotificationListNotifications,
492
+ ),
493
+ },
494
+ )
495
+
496
+ expect(full.data.notifications.length).toBe(4)
497
+ expect(results(paginatedAll)).toEqual(results([full.data]))
420
498
  })
421
499
 
422
500
  it('fails open on clearly bad cursor.', async () => {