@atproto/pds 0.4.139 → 0.4.140
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 +7 -0
- package/dist/lexicon/index.d.ts +6 -2
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +12 -4
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +498 -82
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +259 -42
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadHiddenV2.d.ts +61 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadHiddenV2.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadHiddenV2.js +25 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadHiddenV2.js.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadV2.d.ts +92 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadV2.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadV2.js +52 -0
- package/dist/lexicon/types/app/bsky/unspecced/getPostThreadV2.js.map +1 -0
- package/package.json +5 -5
- package/src/lexicon/index.ts +33 -9
- package/src/lexicon/lexicons.ts +278 -43
- package/src/lexicon/types/app/bsky/unspecced/getPostThreadHiddenV2.ts +93 -0
- package/src/lexicon/types/app/bsky/unspecced/getPostThreadV2.ts +160 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/src/lexicon/lexicons.ts
CHANGED
@@ -7239,48 +7239,6 @@ export const schemaDict = {
|
|
7239
7239
|
},
|
7240
7240
|
},
|
7241
7241
|
},
|
7242
|
-
AppBskyFeedGetPosts: {
|
7243
|
-
lexicon: 1,
|
7244
|
-
id: 'app.bsky.feed.getPosts',
|
7245
|
-
defs: {
|
7246
|
-
main: {
|
7247
|
-
type: 'query',
|
7248
|
-
description:
|
7249
|
-
"Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'.",
|
7250
|
-
parameters: {
|
7251
|
-
type: 'params',
|
7252
|
-
required: ['uris'],
|
7253
|
-
properties: {
|
7254
|
-
uris: {
|
7255
|
-
type: 'array',
|
7256
|
-
description: 'List of post AT-URIs to return hydrated views for.',
|
7257
|
-
items: {
|
7258
|
-
type: 'string',
|
7259
|
-
format: 'at-uri',
|
7260
|
-
},
|
7261
|
-
maxLength: 25,
|
7262
|
-
},
|
7263
|
-
},
|
7264
|
-
},
|
7265
|
-
output: {
|
7266
|
-
encoding: 'application/json',
|
7267
|
-
schema: {
|
7268
|
-
type: 'object',
|
7269
|
-
required: ['posts'],
|
7270
|
-
properties: {
|
7271
|
-
posts: {
|
7272
|
-
type: 'array',
|
7273
|
-
items: {
|
7274
|
-
type: 'ref',
|
7275
|
-
ref: 'lex:app.bsky.feed.defs#postView',
|
7276
|
-
},
|
7277
|
-
},
|
7278
|
-
},
|
7279
|
-
},
|
7280
|
-
},
|
7281
|
-
},
|
7282
|
-
},
|
7283
|
-
},
|
7284
7242
|
AppBskyFeedGetPostThread: {
|
7285
7243
|
lexicon: 1,
|
7286
7244
|
id: 'app.bsky.feed.getPostThread',
|
@@ -7345,6 +7303,48 @@ export const schemaDict = {
|
|
7345
7303
|
},
|
7346
7304
|
},
|
7347
7305
|
},
|
7306
|
+
AppBskyFeedGetPosts: {
|
7307
|
+
lexicon: 1,
|
7308
|
+
id: 'app.bsky.feed.getPosts',
|
7309
|
+
defs: {
|
7310
|
+
main: {
|
7311
|
+
type: 'query',
|
7312
|
+
description:
|
7313
|
+
"Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'.",
|
7314
|
+
parameters: {
|
7315
|
+
type: 'params',
|
7316
|
+
required: ['uris'],
|
7317
|
+
properties: {
|
7318
|
+
uris: {
|
7319
|
+
type: 'array',
|
7320
|
+
description: 'List of post AT-URIs to return hydrated views for.',
|
7321
|
+
items: {
|
7322
|
+
type: 'string',
|
7323
|
+
format: 'at-uri',
|
7324
|
+
},
|
7325
|
+
maxLength: 25,
|
7326
|
+
},
|
7327
|
+
},
|
7328
|
+
},
|
7329
|
+
output: {
|
7330
|
+
encoding: 'application/json',
|
7331
|
+
schema: {
|
7332
|
+
type: 'object',
|
7333
|
+
required: ['posts'],
|
7334
|
+
properties: {
|
7335
|
+
posts: {
|
7336
|
+
type: 'array',
|
7337
|
+
items: {
|
7338
|
+
type: 'ref',
|
7339
|
+
ref: 'lex:app.bsky.feed.defs#postView',
|
7340
|
+
},
|
7341
|
+
},
|
7342
|
+
},
|
7343
|
+
},
|
7344
|
+
},
|
7345
|
+
},
|
7346
|
+
},
|
7347
|
+
},
|
7348
7348
|
AppBskyFeedGetQuotes: {
|
7349
7349
|
lexicon: 1,
|
7350
7350
|
id: 'app.bsky.feed.getQuotes',
|
@@ -10294,6 +10294,238 @@ export const schemaDict = {
|
|
10294
10294
|
},
|
10295
10295
|
},
|
10296
10296
|
},
|
10297
|
+
AppBskyUnspeccedGetPostThreadHiddenV2: {
|
10298
|
+
lexicon: 1,
|
10299
|
+
id: 'app.bsky.unspecced.getPostThreadHiddenV2',
|
10300
|
+
defs: {
|
10301
|
+
main: {
|
10302
|
+
type: 'query',
|
10303
|
+
description:
|
10304
|
+
"(NOTE: this endpoint is under development and WILL change without notice. Don't use it until it is moved out of `unspecced` or your application WILL break) Get the hidden posts in a thread. It is based in an anchor post at any depth of the tree, and returns hidden replies (recursive replies, with branching to their replies) below the anchor. It does not include ancestors nor the anchor. This should be called after exhausting `app.bsky.unspecced.getPostThreadV2`. Does not require auth, but additional metadata and filtering will be applied for authed requests.",
|
10305
|
+
parameters: {
|
10306
|
+
type: 'params',
|
10307
|
+
required: ['anchor'],
|
10308
|
+
properties: {
|
10309
|
+
anchor: {
|
10310
|
+
type: 'string',
|
10311
|
+
format: 'at-uri',
|
10312
|
+
description:
|
10313
|
+
'Reference (AT-URI) to post record. This is the anchor post.',
|
10314
|
+
},
|
10315
|
+
},
|
10316
|
+
},
|
10317
|
+
output: {
|
10318
|
+
encoding: 'application/json',
|
10319
|
+
schema: {
|
10320
|
+
type: 'object',
|
10321
|
+
required: ['thread'],
|
10322
|
+
properties: {
|
10323
|
+
thread: {
|
10324
|
+
type: 'array',
|
10325
|
+
description:
|
10326
|
+
'A flat list of thread hidden items. The depth of each item is indicated by the depth property inside the item.',
|
10327
|
+
items: {
|
10328
|
+
type: 'ref',
|
10329
|
+
ref: 'lex:app.bsky.unspecced.getPostThreadHiddenV2#threadHiddenItem',
|
10330
|
+
},
|
10331
|
+
},
|
10332
|
+
},
|
10333
|
+
},
|
10334
|
+
},
|
10335
|
+
},
|
10336
|
+
threadHiddenItem: {
|
10337
|
+
type: 'object',
|
10338
|
+
required: ['uri', 'depth', 'value'],
|
10339
|
+
properties: {
|
10340
|
+
uri: {
|
10341
|
+
type: 'string',
|
10342
|
+
format: 'at-uri',
|
10343
|
+
},
|
10344
|
+
depth: {
|
10345
|
+
type: 'integer',
|
10346
|
+
description:
|
10347
|
+
'The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths.',
|
10348
|
+
},
|
10349
|
+
value: {
|
10350
|
+
type: 'union',
|
10351
|
+
refs: [
|
10352
|
+
'lex:app.bsky.unspecced.getPostThreadHiddenV2#threadHiddenItemPost',
|
10353
|
+
],
|
10354
|
+
},
|
10355
|
+
},
|
10356
|
+
},
|
10357
|
+
threadHiddenItemPost: {
|
10358
|
+
type: 'object',
|
10359
|
+
required: ['post', 'hiddenByThreadgate', 'mutedByViewer'],
|
10360
|
+
properties: {
|
10361
|
+
post: {
|
10362
|
+
type: 'ref',
|
10363
|
+
ref: 'lex:app.bsky.feed.defs#postView',
|
10364
|
+
},
|
10365
|
+
hiddenByThreadgate: {
|
10366
|
+
type: 'boolean',
|
10367
|
+
description:
|
10368
|
+
'The threadgate created by the author indicates this post as a reply to be hidden for everyone consuming the thread.',
|
10369
|
+
},
|
10370
|
+
mutedByViewer: {
|
10371
|
+
type: 'boolean',
|
10372
|
+
description:
|
10373
|
+
'This is by an account muted by the viewer requesting it.',
|
10374
|
+
},
|
10375
|
+
},
|
10376
|
+
},
|
10377
|
+
},
|
10378
|
+
},
|
10379
|
+
AppBskyUnspeccedGetPostThreadV2: {
|
10380
|
+
lexicon: 1,
|
10381
|
+
id: 'app.bsky.unspecced.getPostThreadV2',
|
10382
|
+
defs: {
|
10383
|
+
main: {
|
10384
|
+
type: 'query',
|
10385
|
+
description:
|
10386
|
+
"(NOTE: this endpoint is under development and WILL change without notice. Don't use it until it is moved out of `unspecced` or your application WILL break) Get posts in a thread. It is based in an anchor post at any depth of the tree, and returns posts above it (recursively resolving the parent, without further branching to their replies) and below it (recursive replies, with branching to their replies). Does not require auth, but additional metadata and filtering will be applied for authed requests.",
|
10387
|
+
parameters: {
|
10388
|
+
type: 'params',
|
10389
|
+
required: ['anchor'],
|
10390
|
+
properties: {
|
10391
|
+
anchor: {
|
10392
|
+
type: 'string',
|
10393
|
+
format: 'at-uri',
|
10394
|
+
description:
|
10395
|
+
'Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post.',
|
10396
|
+
},
|
10397
|
+
above: {
|
10398
|
+
type: 'boolean',
|
10399
|
+
description: 'Whether to include parents above the anchor.',
|
10400
|
+
default: true,
|
10401
|
+
},
|
10402
|
+
below: {
|
10403
|
+
type: 'integer',
|
10404
|
+
description:
|
10405
|
+
'How many levels of replies to include below the anchor.',
|
10406
|
+
default: 6,
|
10407
|
+
minimum: 0,
|
10408
|
+
maximum: 20,
|
10409
|
+
},
|
10410
|
+
branchingFactor: {
|
10411
|
+
type: 'integer',
|
10412
|
+
description:
|
10413
|
+
'Maximum of replies to include at each level of the thread, except for the direct replies to the anchor, which are (NOTE: currently, during unspecced phase) all returned (NOTE: later they might be paginated).',
|
10414
|
+
default: 10,
|
10415
|
+
minimum: 0,
|
10416
|
+
maximum: 100,
|
10417
|
+
},
|
10418
|
+
prioritizeFollowedUsers: {
|
10419
|
+
type: 'boolean',
|
10420
|
+
description:
|
10421
|
+
'Whether to prioritize posts from followed users. It only has effect when the user is authenticated.',
|
10422
|
+
default: false,
|
10423
|
+
},
|
10424
|
+
sort: {
|
10425
|
+
type: 'string',
|
10426
|
+
description: 'Sorting for the thread replies.',
|
10427
|
+
knownValues: ['newest', 'oldest', 'top'],
|
10428
|
+
default: 'oldest',
|
10429
|
+
},
|
10430
|
+
},
|
10431
|
+
},
|
10432
|
+
output: {
|
10433
|
+
encoding: 'application/json',
|
10434
|
+
schema: {
|
10435
|
+
type: 'object',
|
10436
|
+
required: ['thread', 'hasHiddenReplies'],
|
10437
|
+
properties: {
|
10438
|
+
thread: {
|
10439
|
+
type: 'array',
|
10440
|
+
description:
|
10441
|
+
'A flat list of thread items. The depth of each item is indicated by the depth property inside the item.',
|
10442
|
+
items: {
|
10443
|
+
type: 'ref',
|
10444
|
+
ref: 'lex:app.bsky.unspecced.getPostThreadV2#threadItem',
|
10445
|
+
},
|
10446
|
+
},
|
10447
|
+
threadgate: {
|
10448
|
+
type: 'ref',
|
10449
|
+
ref: 'lex:app.bsky.feed.defs#threadgateView',
|
10450
|
+
},
|
10451
|
+
hasHiddenReplies: {
|
10452
|
+
type: 'boolean',
|
10453
|
+
description:
|
10454
|
+
'Whether this thread has hidden replies. If true, a call can be made to the `getPostThreadHiddenV2` endpoint to retrieve them.',
|
10455
|
+
},
|
10456
|
+
},
|
10457
|
+
},
|
10458
|
+
},
|
10459
|
+
},
|
10460
|
+
threadItem: {
|
10461
|
+
type: 'object',
|
10462
|
+
required: ['uri', 'depth', 'value'],
|
10463
|
+
properties: {
|
10464
|
+
uri: {
|
10465
|
+
type: 'string',
|
10466
|
+
format: 'at-uri',
|
10467
|
+
},
|
10468
|
+
depth: {
|
10469
|
+
type: 'integer',
|
10470
|
+
description:
|
10471
|
+
'The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths.',
|
10472
|
+
},
|
10473
|
+
value: {
|
10474
|
+
type: 'union',
|
10475
|
+
refs: [
|
10476
|
+
'lex:app.bsky.unspecced.getPostThreadV2#threadItemPost',
|
10477
|
+
'lex:app.bsky.unspecced.getPostThreadV2#threadItemNoUnauthenticated',
|
10478
|
+
'lex:app.bsky.unspecced.getPostThreadV2#threadItemNotFound',
|
10479
|
+
'lex:app.bsky.unspecced.getPostThreadV2#threadItemBlocked',
|
10480
|
+
],
|
10481
|
+
},
|
10482
|
+
},
|
10483
|
+
},
|
10484
|
+
threadItemPost: {
|
10485
|
+
type: 'object',
|
10486
|
+
required: ['post', 'moreParents', 'moreReplies', 'opThread'],
|
10487
|
+
properties: {
|
10488
|
+
post: {
|
10489
|
+
type: 'ref',
|
10490
|
+
ref: 'lex:app.bsky.feed.defs#postView',
|
10491
|
+
},
|
10492
|
+
moreParents: {
|
10493
|
+
type: 'boolean',
|
10494
|
+
description:
|
10495
|
+
'This post has more parents that were not present in the response. This is just a boolean, without the number of parents.',
|
10496
|
+
},
|
10497
|
+
moreReplies: {
|
10498
|
+
type: 'integer',
|
10499
|
+
description:
|
10500
|
+
'This post has more replies that were not present in the response. This is a numeric value, which is best-effort and might not be accurate.',
|
10501
|
+
},
|
10502
|
+
opThread: {
|
10503
|
+
type: 'boolean',
|
10504
|
+
description:
|
10505
|
+
'This post is part of a contiguous thread by the OP from the thread root. Many different OP threads can happen in the same thread.',
|
10506
|
+
},
|
10507
|
+
},
|
10508
|
+
},
|
10509
|
+
threadItemNoUnauthenticated: {
|
10510
|
+
type: 'object',
|
10511
|
+
properties: {},
|
10512
|
+
},
|
10513
|
+
threadItemNotFound: {
|
10514
|
+
type: 'object',
|
10515
|
+
properties: {},
|
10516
|
+
},
|
10517
|
+
threadItemBlocked: {
|
10518
|
+
type: 'object',
|
10519
|
+
required: ['author'],
|
10520
|
+
properties: {
|
10521
|
+
author: {
|
10522
|
+
type: 'ref',
|
10523
|
+
ref: 'lex:app.bsky.feed.defs#blockedAuthor',
|
10524
|
+
},
|
10525
|
+
},
|
10526
|
+
},
|
10527
|
+
},
|
10528
|
+
},
|
10297
10529
|
AppBskyUnspeccedGetSuggestedFeeds: {
|
10298
10530
|
lexicon: 1,
|
10299
10531
|
id: 'app.bsky.unspecced.getSuggestedFeeds',
|
@@ -16275,8 +16507,8 @@ export const ids = {
|
|
16275
16507
|
AppBskyFeedGetFeedSkeleton: 'app.bsky.feed.getFeedSkeleton',
|
16276
16508
|
AppBskyFeedGetLikes: 'app.bsky.feed.getLikes',
|
16277
16509
|
AppBskyFeedGetListFeed: 'app.bsky.feed.getListFeed',
|
16278
|
-
AppBskyFeedGetPosts: 'app.bsky.feed.getPosts',
|
16279
16510
|
AppBskyFeedGetPostThread: 'app.bsky.feed.getPostThread',
|
16511
|
+
AppBskyFeedGetPosts: 'app.bsky.feed.getPosts',
|
16280
16512
|
AppBskyFeedGetQuotes: 'app.bsky.feed.getQuotes',
|
16281
16513
|
AppBskyFeedGetRepostedBy: 'app.bsky.feed.getRepostedBy',
|
16282
16514
|
AppBskyFeedGetSuggestedFeeds: 'app.bsky.feed.getSuggestedFeeds',
|
@@ -16333,6 +16565,9 @@ export const ids = {
|
|
16333
16565
|
AppBskyUnspeccedGetConfig: 'app.bsky.unspecced.getConfig',
|
16334
16566
|
AppBskyUnspeccedGetPopularFeedGenerators:
|
16335
16567
|
'app.bsky.unspecced.getPopularFeedGenerators',
|
16568
|
+
AppBskyUnspeccedGetPostThreadHiddenV2:
|
16569
|
+
'app.bsky.unspecced.getPostThreadHiddenV2',
|
16570
|
+
AppBskyUnspeccedGetPostThreadV2: 'app.bsky.unspecced.getPostThreadV2',
|
16336
16571
|
AppBskyUnspeccedGetSuggestedFeeds: 'app.bsky.unspecced.getSuggestedFeeds',
|
16337
16572
|
AppBskyUnspeccedGetSuggestedFeedsSkeleton:
|
16338
16573
|
'app.bsky.unspecced.getSuggestedFeedsSkeleton',
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/**
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
3
|
+
*/
|
4
|
+
import express from 'express'
|
5
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
6
|
+
import { CID } from 'multiformats/cid'
|
7
|
+
import { validate as _validate } from '../../../../lexicons'
|
8
|
+
import {
|
9
|
+
type $Typed,
|
10
|
+
is$typed as _is$typed,
|
11
|
+
type OmitKey,
|
12
|
+
} from '../../../../util'
|
13
|
+
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
|
14
|
+
import type * as AppBskyFeedDefs from '../feed/defs.js'
|
15
|
+
|
16
|
+
const is$typed = _is$typed,
|
17
|
+
validate = _validate
|
18
|
+
const id = 'app.bsky.unspecced.getPostThreadHiddenV2'
|
19
|
+
|
20
|
+
export interface QueryParams {
|
21
|
+
/** Reference (AT-URI) to post record. This is the anchor post. */
|
22
|
+
anchor: string
|
23
|
+
}
|
24
|
+
|
25
|
+
export type InputSchema = undefined
|
26
|
+
|
27
|
+
export interface OutputSchema {
|
28
|
+
/** A flat list of thread hidden items. The depth of each item is indicated by the depth property inside the item. */
|
29
|
+
thread: ThreadHiddenItem[]
|
30
|
+
}
|
31
|
+
|
32
|
+
export type HandlerInput = undefined
|
33
|
+
|
34
|
+
export interface HandlerSuccess {
|
35
|
+
encoding: 'application/json'
|
36
|
+
body: OutputSchema
|
37
|
+
headers?: { [key: string]: string }
|
38
|
+
}
|
39
|
+
|
40
|
+
export interface HandlerError {
|
41
|
+
status: number
|
42
|
+
message?: string
|
43
|
+
}
|
44
|
+
|
45
|
+
export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
|
46
|
+
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
47
|
+
auth: HA
|
48
|
+
params: QueryParams
|
49
|
+
input: HandlerInput
|
50
|
+
req: express.Request
|
51
|
+
res: express.Response
|
52
|
+
resetRouteRateLimits: () => Promise<void>
|
53
|
+
}
|
54
|
+
export type Handler<HA extends HandlerAuth = never> = (
|
55
|
+
ctx: HandlerReqCtx<HA>,
|
56
|
+
) => Promise<HandlerOutput> | HandlerOutput
|
57
|
+
|
58
|
+
export interface ThreadHiddenItem {
|
59
|
+
$type?: 'app.bsky.unspecced.getPostThreadHiddenV2#threadHiddenItem'
|
60
|
+
uri: string
|
61
|
+
/** The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths. */
|
62
|
+
depth: number
|
63
|
+
value: $Typed<ThreadHiddenItemPost> | { $type: string }
|
64
|
+
}
|
65
|
+
|
66
|
+
const hashThreadHiddenItem = 'threadHiddenItem'
|
67
|
+
|
68
|
+
export function isThreadHiddenItem<V>(v: V) {
|
69
|
+
return is$typed(v, id, hashThreadHiddenItem)
|
70
|
+
}
|
71
|
+
|
72
|
+
export function validateThreadHiddenItem<V>(v: V) {
|
73
|
+
return validate<ThreadHiddenItem & V>(v, id, hashThreadHiddenItem)
|
74
|
+
}
|
75
|
+
|
76
|
+
export interface ThreadHiddenItemPost {
|
77
|
+
$type?: 'app.bsky.unspecced.getPostThreadHiddenV2#threadHiddenItemPost'
|
78
|
+
post: AppBskyFeedDefs.PostView
|
79
|
+
/** The threadgate created by the author indicates this post as a reply to be hidden for everyone consuming the thread. */
|
80
|
+
hiddenByThreadgate: boolean
|
81
|
+
/** This is by an account muted by the viewer requesting it. */
|
82
|
+
mutedByViewer: boolean
|
83
|
+
}
|
84
|
+
|
85
|
+
const hashThreadHiddenItemPost = 'threadHiddenItemPost'
|
86
|
+
|
87
|
+
export function isThreadHiddenItemPost<V>(v: V) {
|
88
|
+
return is$typed(v, id, hashThreadHiddenItemPost)
|
89
|
+
}
|
90
|
+
|
91
|
+
export function validateThreadHiddenItemPost<V>(v: V) {
|
92
|
+
return validate<ThreadHiddenItemPost & V>(v, id, hashThreadHiddenItemPost)
|
93
|
+
}
|
@@ -0,0 +1,160 @@
|
|
1
|
+
/**
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
3
|
+
*/
|
4
|
+
import express from 'express'
|
5
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon'
|
6
|
+
import { CID } from 'multiformats/cid'
|
7
|
+
import { validate as _validate } from '../../../../lexicons'
|
8
|
+
import {
|
9
|
+
type $Typed,
|
10
|
+
is$typed as _is$typed,
|
11
|
+
type OmitKey,
|
12
|
+
} from '../../../../util'
|
13
|
+
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
|
14
|
+
import type * as AppBskyFeedDefs from '../feed/defs.js'
|
15
|
+
|
16
|
+
const is$typed = _is$typed,
|
17
|
+
validate = _validate
|
18
|
+
const id = 'app.bsky.unspecced.getPostThreadV2'
|
19
|
+
|
20
|
+
export interface QueryParams {
|
21
|
+
/** Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post. */
|
22
|
+
anchor: string
|
23
|
+
/** Whether to include parents above the anchor. */
|
24
|
+
above: boolean
|
25
|
+
/** How many levels of replies to include below the anchor. */
|
26
|
+
below: number
|
27
|
+
/** Maximum of replies to include at each level of the thread, except for the direct replies to the anchor, which are (NOTE: currently, during unspecced phase) all returned (NOTE: later they might be paginated). */
|
28
|
+
branchingFactor: number
|
29
|
+
/** Whether to prioritize posts from followed users. It only has effect when the user is authenticated. */
|
30
|
+
prioritizeFollowedUsers: boolean
|
31
|
+
/** Sorting for the thread replies. */
|
32
|
+
sort: 'newest' | 'oldest' | 'top' | (string & {})
|
33
|
+
}
|
34
|
+
|
35
|
+
export type InputSchema = undefined
|
36
|
+
|
37
|
+
export interface OutputSchema {
|
38
|
+
/** A flat list of thread items. The depth of each item is indicated by the depth property inside the item. */
|
39
|
+
thread: ThreadItem[]
|
40
|
+
threadgate?: AppBskyFeedDefs.ThreadgateView
|
41
|
+
/** Whether this thread has hidden replies. If true, a call can be made to the `getPostThreadHiddenV2` endpoint to retrieve them. */
|
42
|
+
hasHiddenReplies: boolean
|
43
|
+
}
|
44
|
+
|
45
|
+
export type HandlerInput = undefined
|
46
|
+
|
47
|
+
export interface HandlerSuccess {
|
48
|
+
encoding: 'application/json'
|
49
|
+
body: OutputSchema
|
50
|
+
headers?: { [key: string]: string }
|
51
|
+
}
|
52
|
+
|
53
|
+
export interface HandlerError {
|
54
|
+
status: number
|
55
|
+
message?: string
|
56
|
+
}
|
57
|
+
|
58
|
+
export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
|
59
|
+
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
|
60
|
+
auth: HA
|
61
|
+
params: QueryParams
|
62
|
+
input: HandlerInput
|
63
|
+
req: express.Request
|
64
|
+
res: express.Response
|
65
|
+
resetRouteRateLimits: () => Promise<void>
|
66
|
+
}
|
67
|
+
export type Handler<HA extends HandlerAuth = never> = (
|
68
|
+
ctx: HandlerReqCtx<HA>,
|
69
|
+
) => Promise<HandlerOutput> | HandlerOutput
|
70
|
+
|
71
|
+
export interface ThreadItem {
|
72
|
+
$type?: 'app.bsky.unspecced.getPostThreadV2#threadItem'
|
73
|
+
uri: string
|
74
|
+
/** The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths. */
|
75
|
+
depth: number
|
76
|
+
value:
|
77
|
+
| $Typed<ThreadItemPost>
|
78
|
+
| $Typed<ThreadItemNoUnauthenticated>
|
79
|
+
| $Typed<ThreadItemNotFound>
|
80
|
+
| $Typed<ThreadItemBlocked>
|
81
|
+
| { $type: string }
|
82
|
+
}
|
83
|
+
|
84
|
+
const hashThreadItem = 'threadItem'
|
85
|
+
|
86
|
+
export function isThreadItem<V>(v: V) {
|
87
|
+
return is$typed(v, id, hashThreadItem)
|
88
|
+
}
|
89
|
+
|
90
|
+
export function validateThreadItem<V>(v: V) {
|
91
|
+
return validate<ThreadItem & V>(v, id, hashThreadItem)
|
92
|
+
}
|
93
|
+
|
94
|
+
export interface ThreadItemPost {
|
95
|
+
$type?: 'app.bsky.unspecced.getPostThreadV2#threadItemPost'
|
96
|
+
post: AppBskyFeedDefs.PostView
|
97
|
+
/** This post has more parents that were not present in the response. This is just a boolean, without the number of parents. */
|
98
|
+
moreParents: boolean
|
99
|
+
/** This post has more replies that were not present in the response. This is a numeric value, which is best-effort and might not be accurate. */
|
100
|
+
moreReplies: number
|
101
|
+
/** This post is part of a contiguous thread by the OP from the thread root. Many different OP threads can happen in the same thread. */
|
102
|
+
opThread: boolean
|
103
|
+
}
|
104
|
+
|
105
|
+
const hashThreadItemPost = 'threadItemPost'
|
106
|
+
|
107
|
+
export function isThreadItemPost<V>(v: V) {
|
108
|
+
return is$typed(v, id, hashThreadItemPost)
|
109
|
+
}
|
110
|
+
|
111
|
+
export function validateThreadItemPost<V>(v: V) {
|
112
|
+
return validate<ThreadItemPost & V>(v, id, hashThreadItemPost)
|
113
|
+
}
|
114
|
+
|
115
|
+
export interface ThreadItemNoUnauthenticated {
|
116
|
+
$type?: 'app.bsky.unspecced.getPostThreadV2#threadItemNoUnauthenticated'
|
117
|
+
}
|
118
|
+
|
119
|
+
const hashThreadItemNoUnauthenticated = 'threadItemNoUnauthenticated'
|
120
|
+
|
121
|
+
export function isThreadItemNoUnauthenticated<V>(v: V) {
|
122
|
+
return is$typed(v, id, hashThreadItemNoUnauthenticated)
|
123
|
+
}
|
124
|
+
|
125
|
+
export function validateThreadItemNoUnauthenticated<V>(v: V) {
|
126
|
+
return validate<ThreadItemNoUnauthenticated & V>(
|
127
|
+
v,
|
128
|
+
id,
|
129
|
+
hashThreadItemNoUnauthenticated,
|
130
|
+
)
|
131
|
+
}
|
132
|
+
|
133
|
+
export interface ThreadItemNotFound {
|
134
|
+
$type?: 'app.bsky.unspecced.getPostThreadV2#threadItemNotFound'
|
135
|
+
}
|
136
|
+
|
137
|
+
const hashThreadItemNotFound = 'threadItemNotFound'
|
138
|
+
|
139
|
+
export function isThreadItemNotFound<V>(v: V) {
|
140
|
+
return is$typed(v, id, hashThreadItemNotFound)
|
141
|
+
}
|
142
|
+
|
143
|
+
export function validateThreadItemNotFound<V>(v: V) {
|
144
|
+
return validate<ThreadItemNotFound & V>(v, id, hashThreadItemNotFound)
|
145
|
+
}
|
146
|
+
|
147
|
+
export interface ThreadItemBlocked {
|
148
|
+
$type?: 'app.bsky.unspecced.getPostThreadV2#threadItemBlocked'
|
149
|
+
author: AppBskyFeedDefs.BlockedAuthor
|
150
|
+
}
|
151
|
+
|
152
|
+
const hashThreadItemBlocked = 'threadItemBlocked'
|
153
|
+
|
154
|
+
export function isThreadItemBlocked<V>(v: V) {
|
155
|
+
return is$typed(v, id, hashThreadItemBlocked)
|
156
|
+
}
|
157
|
+
|
158
|
+
export function validateThreadItemBlocked<V>(v: V) {
|
159
|
+
return validate<ThreadItemBlocked & V>(v, id, hashThreadItemBlocked)
|
160
|
+
}
|