@atproto/bsky 0.0.251 → 0.0.253
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 +35 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.js.map +1 -1
- package/dist/kws.d.ts +8 -0
- package/dist/kws.d.ts.map +1 -1
- package/dist/kws.js +53 -4
- package/dist/kws.js.map +1 -1
- package/package.json +28 -23
- package/bin/migration-create.ts +0 -46
- package/buf.gen.yaml +0 -12
- package/proto/bsky.proto +0 -1907
- package/proto/courier.proto +0 -84
- package/proto/rolodex.proto +0 -116
- package/src/api/age-assurance/const.ts +0 -203
- package/src/api/age-assurance/index.ts +0 -34
- package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
- package/src/api/age-assurance/kws/age-verified.ts +0 -81
- package/src/api/age-assurance/kws/const.ts +0 -33
- package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
- package/src/api/age-assurance/kws/external-payload.ts +0 -149
- package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
- package/src/api/age-assurance/stash.ts +0 -23
- package/src/api/age-assurance/types.ts +0 -10
- package/src/api/age-assurance/util.ts +0 -68
- package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
- package/src/api/app/bsky/actor/getProfile.ts +0 -106
- package/src/api/app/bsky/actor/getProfiles.ts +0 -99
- package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
- package/src/api/app/bsky/actor/searchActors.ts +0 -171
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
- package/src/api/app/bsky/ageassurance/begin.ts +0 -175
- package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
- package/src/api/app/bsky/ageassurance/getState.ts +0 -58
- package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
- package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
- package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
- package/src/api/app/bsky/bookmark/util.ts +0 -13
- package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
- package/src/api/app/bsky/contact/getMatches.ts +0 -111
- package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
- package/src/api/app/bsky/contact/importContacts.ts +0 -119
- package/src/api/app/bsky/contact/removeData.ts +0 -25
- package/src/api/app/bsky/contact/sendNotification.ts +0 -33
- package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
- package/src/api/app/bsky/contact/util.ts +0 -92
- package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
- package/src/api/app/bsky/draft/createDraft.ts +0 -45
- package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
- package/src/api/app/bsky/draft/getDrafts.ts +0 -44
- package/src/api/app/bsky/draft/updateDraft.ts +0 -26
- package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
- package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
- package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
- package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
- package/src/api/app/bsky/feed/getFeed.ts +0 -282
- package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
- package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
- package/src/api/app/bsky/feed/getLikes.ts +0 -151
- package/src/api/app/bsky/feed/getListFeed.ts +0 -147
- package/src/api/app/bsky/feed/getPostThread.ts +0 -156
- package/src/api/app/bsky/feed/getPosts.ts +0 -100
- package/src/api/app/bsky/feed/getQuotes.ts +0 -122
- package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
- package/src/api/app/bsky/feed/getTimeline.ts +0 -127
- package/src/api/app/bsky/feed/searchPosts.ts +0 -274
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -243
- package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
- package/src/api/app/bsky/graph/getBlocks.ts +0 -94
- package/src/api/app/bsky/graph/getFollowers.ts +0 -153
- package/src/api/app/bsky/graph/getFollows.ts +0 -151
- package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
- package/src/api/app/bsky/graph/getList.ts +0 -152
- package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
- package/src/api/app/bsky/graph/getListMutes.ts +0 -87
- package/src/api/app/bsky/graph/getLists.ts +0 -125
- package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
- package/src/api/app/bsky/graph/getMutes.ts +0 -87
- package/src/api/app/bsky/graph/getRelationships.ts +0 -58
- package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
- package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
- package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
- package/src/api/app/bsky/graph/muteActor.ts +0 -24
- package/src/api/app/bsky/graph/muteActorList.ts +0 -19
- package/src/api/app/bsky/graph/muteThread.ts +0 -19
- package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
- package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
- package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
- package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
- package/src/api/app/bsky/labeler/getServices.ts +0 -41
- package/src/api/app/bsky/notification/getPreferences.ts +0 -49
- package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
- package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
- package/src/api/app/bsky/notification/listNotifications.ts +0 -272
- package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
- package/src/api/app/bsky/notification/putPreferences.ts +0 -17
- package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
- package/src/api/app/bsky/notification/registerPush.ts +0 -40
- package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
- package/src/api/app/bsky/notification/updateSeen.ts +0 -52
- package/src/api/app/bsky/notification/util.ts +0 -134
- package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
- package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
- package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
- package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
- package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
- package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
- package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
- package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
- package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
- package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
- package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
- package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
- package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
- package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
- package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
- package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
- package/src/api/blob-dispatcher.ts +0 -41
- package/src/api/blob-resolver.ts +0 -401
- package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
- package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
- package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
- package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
- package/src/api/com/atproto/label/queryLabels.ts +0 -42
- package/src/api/com/atproto/repo/getRecord.ts +0 -44
- package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
- package/src/api/external.ts +0 -15
- package/src/api/health.ts +0 -47
- package/src/api/index.ts +0 -216
- package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
- package/src/api/kws/api.ts +0 -113
- package/src/api/kws/index.ts +0 -29
- package/src/api/kws/types.ts +0 -78
- package/src/api/kws/util.test.ts +0 -50
- package/src/api/kws/util.ts +0 -109
- package/src/api/kws/webhook.ts +0 -134
- package/src/api/sitemap.ts +0 -76
- package/src/api/util.ts +0 -45
- package/src/api/well-known.ts +0 -44
- package/src/auth-verifier.ts +0 -522
- package/src/bsync.ts +0 -41
- package/src/cache/read-through.ts +0 -157
- package/src/config.ts +0 -719
- package/src/context.ts +0 -143
- package/src/courier.ts +0 -41
- package/src/data-plane/client/hosts.ts +0 -103
- package/src/data-plane/client/index.ts +0 -125
- package/src/data-plane/client/util.test.ts +0 -29
- package/src/data-plane/client/util.ts +0 -74
- package/src/data-plane/index.ts +0 -2
- package/src/data-plane/server/background.ts +0 -66
- package/src/data-plane/server/bsync-subscription.ts +0 -590
- package/src/data-plane/server/db/database-schema.ts +0 -90
- package/src/data-plane/server/db/db.ts +0 -204
- package/src/data-plane/server/db/index.ts +0 -2
- package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
- package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
- package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
- package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
- package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
- package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
- package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
- package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
- package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
- package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
- package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
- package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
- package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
- package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
- package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
- package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
- package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
- package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
- package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
- package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
- package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
- package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
- package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
- package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
- package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
- package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
- package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
- package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
- package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
- package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
- package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
- package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
- package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
- package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
- package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
- package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
- package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
- package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
- package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
- package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
- package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
- package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
- package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
- package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
- package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
- package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
- package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
- package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
- package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
- package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
- package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
- package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
- package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
- package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
- package/src/data-plane/server/db/migrations/index.ts +0 -60
- package/src/data-plane/server/db/migrations/provider.ts +0 -26
- package/src/data-plane/server/db/pagination.ts +0 -341
- package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
- package/src/data-plane/server/db/tables/actor-block.ts +0 -14
- package/src/data-plane/server/db/tables/actor-state.ts +0 -10
- package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
- package/src/data-plane/server/db/tables/actor.ts +0 -19
- package/src/data-plane/server/db/tables/algo.ts +0 -11
- package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
- package/src/data-plane/server/db/tables/bookmark.ts +0 -11
- package/src/data-plane/server/db/tables/did-cache.ts +0 -13
- package/src/data-plane/server/db/tables/draft.ts +0 -11
- package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
- package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
- package/src/data-plane/server/db/tables/feed-item.ts +0 -12
- package/src/data-plane/server/db/tables/follow.ts +0 -15
- package/src/data-plane/server/db/tables/label.ts +0 -13
- package/src/data-plane/server/db/tables/labeler.ts +0 -16
- package/src/data-plane/server/db/tables/like.ts +0 -18
- package/src/data-plane/server/db/tables/list-block.ts +0 -15
- package/src/data-plane/server/db/tables/list-item.ts +0 -16
- package/src/data-plane/server/db/tables/list-mute.ts +0 -9
- package/src/data-plane/server/db/tables/list.ts +0 -19
- package/src/data-plane/server/db/tables/mute.ts +0 -9
- package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
- package/src/data-plane/server/db/tables/notification.ts +0 -16
- package/src/data-plane/server/db/tables/post-agg.ts +0 -16
- package/src/data-plane/server/db/tables/post-embed.ts +0 -47
- package/src/data-plane/server/db/tables/post-gate.ts +0 -12
- package/src/data-plane/server/db/tables/post.ts +0 -28
- package/src/data-plane/server/db/tables/private-data.ts +0 -13
- package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
- package/src/data-plane/server/db/tables/profile.ts +0 -17
- package/src/data-plane/server/db/tables/quote.ts +0 -15
- package/src/data-plane/server/db/tables/record.ts +0 -15
- package/src/data-plane/server/db/tables/repost.ts +0 -18
- package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
- package/src/data-plane/server/db/tables/subscription.ts +0 -9
- package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
- package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
- package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
- package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
- package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
- package/src/data-plane/server/db/tables/verification.ts +0 -20
- package/src/data-plane/server/db/tables/view-param.ts +0 -12
- package/src/data-plane/server/db/types.ts +0 -12
- package/src/data-plane/server/db/util.ts +0 -67
- package/src/data-plane/server/index.ts +0 -44
- package/src/data-plane/server/indexing/index.ts +0 -458
- package/src/data-plane/server/indexing/plugins/block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
- package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
- package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
- package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
- package/src/data-plane/server/indexing/plugins/like.ts +0 -151
- package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
- package/src/data-plane/server/indexing/plugins/list.ts +0 -80
- package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/post.ts +0 -675
- package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
- package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
- package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
- package/src/data-plane/server/indexing/plugins/status.ts +0 -57
- package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
- package/src/data-plane/server/indexing/processor.ts +0 -292
- package/src/data-plane/server/routes/activity-subscription.ts +0 -84
- package/src/data-plane/server/routes/blocks.ts +0 -127
- package/src/data-plane/server/routes/bookmarks.ts +0 -83
- package/src/data-plane/server/routes/drafts.ts +0 -37
- package/src/data-plane/server/routes/feed-gens.ts +0 -89
- package/src/data-plane/server/routes/feeds.ts +0 -176
- package/src/data-plane/server/routes/follows.ts +0 -141
- package/src/data-plane/server/routes/identity.ts +0 -59
- package/src/data-plane/server/routes/index.ts +0 -67
- package/src/data-plane/server/routes/interactions.ts +0 -120
- package/src/data-plane/server/routes/labels.ts +0 -55
- package/src/data-plane/server/routes/likes.ts +0 -92
- package/src/data-plane/server/routes/lists.ts +0 -88
- package/src/data-plane/server/routes/moderation.ts +0 -102
- package/src/data-plane/server/routes/mutes.ts +0 -195
- package/src/data-plane/server/routes/notifs.ts +0 -239
- package/src/data-plane/server/routes/profile.ts +0 -220
- package/src/data-plane/server/routes/quotes.ts +0 -32
- package/src/data-plane/server/routes/records.ts +0 -119
- package/src/data-plane/server/routes/relationships.ts +0 -174
- package/src/data-plane/server/routes/reposts.ts +0 -76
- package/src/data-plane/server/routes/search.ts +0 -181
- package/src/data-plane/server/routes/site-standard.ts +0 -12
- package/src/data-plane/server/routes/sitemap.ts +0 -43
- package/src/data-plane/server/routes/starter-packs.ts +0 -32
- package/src/data-plane/server/routes/suggestions.ts +0 -175
- package/src/data-plane/server/routes/sync.ts +0 -16
- package/src/data-plane/server/routes/threads.ts +0 -33
- package/src/data-plane/server/subscription.ts +0 -152
- package/src/data-plane/server/util.ts +0 -202
- package/src/error.ts +0 -12
- package/src/etcd.ts +0 -90
- package/src/feature-gates/README.md +0 -83
- package/src/feature-gates/gates.ts +0 -25
- package/src/feature-gates/index.ts +0 -235
- package/src/feature-gates/metrics.test.ts +0 -196
- package/src/feature-gates/metrics.ts +0 -107
- package/src/feature-gates/types.ts +0 -62
- package/src/feature-gates/utils.test.ts +0 -66
- package/src/feature-gates/utils.ts +0 -135
- package/src/hydration/actor.ts +0 -578
- package/src/hydration/external.test.ts +0 -281
- package/src/hydration/external.ts +0 -268
- package/src/hydration/feed.ts +0 -455
- package/src/hydration/graph.ts +0 -354
- package/src/hydration/hydrator.ts +0 -1835
- package/src/hydration/label.ts +0 -207
- package/src/hydration/util.ts +0 -199
- package/src/image/index.ts +0 -2
- package/src/image/invalidator.ts +0 -33
- package/src/image/logger.ts +0 -6
- package/src/image/server.ts +0 -228
- package/src/image/sharp.ts +0 -89
- package/src/image/uri.ts +0 -114
- package/src/image/util.ts +0 -41
- package/src/index.ts +0 -312
- package/src/kws.ts +0 -197
- package/src/logger.ts +0 -40
- package/src/pipeline.ts +0 -60
- package/src/redis.ts +0 -205
- package/src/rolodex.ts +0 -42
- package/src/stash.ts +0 -76
- package/src/util/debug.ts +0 -10
- package/src/util/http.ts +0 -42
- package/src/util/retry.ts +0 -10
- package/src/util/standard-site.test.ts +0 -423
- package/src/util/standard-site.ts +0 -196
- package/src/util/uris.ts +0 -38
- package/src/util.ts +0 -48
- package/src/views/index.ts +0 -2783
- package/src/views/threads-v2.ts +0 -510
- package/src/views/types.ts +0 -193
- package/src/views/util.ts +0 -114
- package/test.env +0 -2
- package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2510
- package/tests/_util.ts +0 -292
- package/tests/admin/admin-auth.test.ts +0 -190
- package/tests/admin/moderation.test.ts +0 -222
- package/tests/auth.test.ts +0 -90
- package/tests/blob-resolver.test.ts +0 -125
- package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
- package/tests/data-plane/db.test.ts +0 -189
- package/tests/data-plane/duplicate-records.test.ts +0 -156
- package/tests/data-plane/handle-invalidation.test.ts +0 -153
- package/tests/data-plane/indexing.test.ts +0 -827
- package/tests/data-plane/subscription.test.ts +0 -128
- package/tests/data-plane/thread-mutes.test.ts +0 -175
- package/tests/entryway-auth.test.ts +0 -177
- package/tests/etcd.test.ts +0 -302
- package/tests/feed-generation.test.ts +0 -965
- package/tests/hydration/util.test.ts +0 -119
- package/tests/image/server.test.ts +0 -97
- package/tests/image/sharp.test.ts +0 -199
- package/tests/image/uri.test.ts +0 -106
- package/tests/label-hydration.test.ts +0 -245
- package/tests/postgates.test.ts +0 -182
- package/tests/query-labels.test.ts +0 -85
- package/tests/redis-cache.test.ts +0 -230
- package/tests/seed/feed-hidden-replies.ts +0 -63
- package/tests/seed/get-suggested-starter-packs.ts +0 -64
- package/tests/seed/get-trends.ts +0 -71
- package/tests/seed/known-followers.ts +0 -111
- package/tests/seed/postgates.ts +0 -57
- package/tests/server.test.ts +0 -115
- package/tests/sitemap.test.ts +0 -75
- package/tests/stash.test.ts +0 -180
- package/tests/utils.test.ts +0 -36
- package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
- package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
- package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
- package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
- package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
- package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
- package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
- package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
- package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
- package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
- package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
- package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
- package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
- package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
- package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
- package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
- package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
- package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
- package/tests/views/account-deactivation.test.ts +0 -81
- package/tests/views/actor-likes.test.ts +0 -138
- package/tests/views/actor-search.test.ts +0 -261
- package/tests/views/age-assurance-v2.test.ts +0 -823
- package/tests/views/age-assurance.test.ts +0 -479
- package/tests/views/author-feed.test.ts +0 -694
- package/tests/views/block-lists.test.ts +0 -661
- package/tests/views/blocks.test.ts +0 -889
- package/tests/views/bookmarks.test.ts +0 -345
- package/tests/views/drafts.test.ts +0 -430
- package/tests/views/feed-hidden-replies.test.ts +0 -243
- package/tests/views/feed-view-post.test.ts +0 -501
- package/tests/views/follows.test.ts +0 -372
- package/tests/views/get-config.test.ts +0 -64
- package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
- package/tests/views/get-suggested-starter-packs.test.ts +0 -137
- package/tests/views/get-trends.test.ts +0 -141
- package/tests/views/internal-actor.test.ts +0 -127
- package/tests/views/known-followers.test.ts +0 -193
- package/tests/views/labeler-service.test.ts +0 -242
- package/tests/views/labels-needs-review.test.ts +0 -316
- package/tests/views/labels-takedown.test.ts +0 -247
- package/tests/views/likes.test.ts +0 -192
- package/tests/views/list-feed.test.ts +0 -195
- package/tests/views/lists.test.ts +0 -412
- package/tests/views/mute-lists.test.ts +0 -509
- package/tests/views/mutes.test.ts +0 -308
- package/tests/views/notifications.test.ts +0 -1581
- package/tests/views/post-search.test.ts +0 -281
- package/tests/views/posts-debug.test.ts +0 -79
- package/tests/views/posts.test.ts +0 -427
- package/tests/views/profile-debug.test.ts +0 -75
- package/tests/views/profile.test.ts +0 -795
- package/tests/views/quotes.test.ts +0 -133
- package/tests/views/reposts.test.ts +0 -112
- package/tests/views/starter-packs.test.ts +0 -395
- package/tests/views/suggestions.test.ts +0 -145
- package/tests/views/thread-v2.test.ts +0 -2005
- package/tests/views/thread.test.ts +0 -637
- package/tests/views/threadgating.test.ts +0 -843
- package/tests/views/timeline.test.ts +0 -328
- package/tests/views/verification.test.ts +0 -296
- package/tsconfig.build.json +0 -10
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -8
- package/vitest.config.ts +0 -10
package/src/views/threads-v2.ts
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { $Typed } from '@atproto/lex'
|
|
2
|
-
import { HydrateCtx } from '../hydration/hydrator.js'
|
|
3
|
-
import {
|
|
4
|
-
GetPostThreadV2QueryParams,
|
|
5
|
-
ThreadItem,
|
|
6
|
-
ThreadItemBlocked,
|
|
7
|
-
ThreadItemNoUnauthenticated,
|
|
8
|
-
ThreadItemNotFound,
|
|
9
|
-
ThreadItemPost,
|
|
10
|
-
ThreadOtherItem,
|
|
11
|
-
} from './types.js'
|
|
12
|
-
|
|
13
|
-
type ThreadMaybeOtherPostNode = ThreadPostNode | ThreadOtherPostNode
|
|
14
|
-
type ThreadNodeWithReplies =
|
|
15
|
-
| ThreadPostNode
|
|
16
|
-
| ThreadOtherPostNode
|
|
17
|
-
| ThreadOtherAnchorPostNode
|
|
18
|
-
|
|
19
|
-
type ThreadItemValue<T extends ThreadItem['value']> = Omit<
|
|
20
|
-
ThreadItem,
|
|
21
|
-
'value'
|
|
22
|
-
> & {
|
|
23
|
-
value: T
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type ThreadItemValueBlocked = ThreadItemValue<$Typed<ThreadItemBlocked>>
|
|
27
|
-
|
|
28
|
-
export type ThreadItemValueNoUnauthenticated = ThreadItemValue<
|
|
29
|
-
$Typed<ThreadItemNoUnauthenticated>
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
export type ThreadItemValueNotFound = ThreadItemValue<
|
|
33
|
-
$Typed<ThreadItemNotFound>
|
|
34
|
-
>
|
|
35
|
-
|
|
36
|
-
export type ThreadItemValuePost = ThreadItemValue<$Typed<ThreadItemPost>>
|
|
37
|
-
|
|
38
|
-
type ThreadBlockedNode = {
|
|
39
|
-
type: 'blocked'
|
|
40
|
-
item: ThreadItemValueBlocked
|
|
41
|
-
}
|
|
42
|
-
type ThreadNoUnauthenticatedNode = {
|
|
43
|
-
type: 'noUnauthenticated'
|
|
44
|
-
parent: ThreadTree | undefined
|
|
45
|
-
item: ThreadItemValueNoUnauthenticated
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type ThreadNotFoundNode = {
|
|
49
|
-
type: 'notFound'
|
|
50
|
-
item: ThreadItemValueNotFound
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type ThreadPostNode = {
|
|
54
|
-
type: 'post'
|
|
55
|
-
item: ThreadItemValuePost
|
|
56
|
-
tags: Set<string>
|
|
57
|
-
hasOPLike: boolean
|
|
58
|
-
parent: ThreadTree | undefined
|
|
59
|
-
replies: ThreadTree[] | undefined
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type ThreadOtherItemValue<T extends ThreadOtherItem['value']> = Omit<
|
|
63
|
-
ThreadOtherItem,
|
|
64
|
-
'value'
|
|
65
|
-
> & {
|
|
66
|
-
value: T
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type ThreadOtherItemValuePost = ThreadOtherItemValue<
|
|
70
|
-
$Typed<ThreadItemPost>
|
|
71
|
-
>
|
|
72
|
-
|
|
73
|
-
// This is an intermediary type that doesn't map to the views.
|
|
74
|
-
// It is useful to differentiate between the anchor post and the replies for the hidden case,
|
|
75
|
-
// while also differentiating between hidden and visible cases.
|
|
76
|
-
export type ThreadOtherAnchorPostNode = {
|
|
77
|
-
type: 'hiddenAnchor'
|
|
78
|
-
item: Omit<ThreadOtherItem, 'value'> & { value: undefined }
|
|
79
|
-
replies: ThreadOtherPostNode[] | undefined
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export type ThreadOtherPostNode = {
|
|
83
|
-
type: 'hiddenPost'
|
|
84
|
-
item: ThreadOtherItemValuePost
|
|
85
|
-
tags: Set<string>
|
|
86
|
-
replies: ThreadOtherPostNode[] | undefined
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const isNodeWithReplies = (node: ThreadTree): node is ThreadNodeWithReplies =>
|
|
90
|
-
'replies' in node && node.replies !== undefined
|
|
91
|
-
|
|
92
|
-
const isPostNode = (node: ThreadTree): node is ThreadMaybeOtherPostNode =>
|
|
93
|
-
node.type === 'post' || node.type === 'hiddenPost'
|
|
94
|
-
|
|
95
|
-
export type ThreadTreeVisible =
|
|
96
|
-
| ThreadBlockedNode
|
|
97
|
-
| ThreadNoUnauthenticatedNode
|
|
98
|
-
| ThreadNotFoundNode
|
|
99
|
-
| ThreadPostNode
|
|
100
|
-
|
|
101
|
-
export type ThreadTreeOther = ThreadOtherAnchorPostNode | ThreadOtherPostNode
|
|
102
|
-
|
|
103
|
-
export type ThreadTree = ThreadTreeVisible | ThreadTreeOther
|
|
104
|
-
|
|
105
|
-
/** This function mutates the tree parameter. */
|
|
106
|
-
export function sortTrimFlattenThreadTree(
|
|
107
|
-
anchorTree: ThreadTree,
|
|
108
|
-
options: SortTrimFlattenOptions,
|
|
109
|
-
useExploration?: boolean,
|
|
110
|
-
) {
|
|
111
|
-
const sortedAnchorTree = useExploration
|
|
112
|
-
? sortTrimThreadTreeExploration(anchorTree, options)
|
|
113
|
-
: sortTrimThreadTree(anchorTree, options)
|
|
114
|
-
|
|
115
|
-
return flattenTree(sortedAnchorTree)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
type SortTrimFlattenOptions = {
|
|
119
|
-
branchingFactor: GetPostThreadV2QueryParams['branchingFactor']
|
|
120
|
-
opDid: string
|
|
121
|
-
sort?: GetPostThreadV2QueryParams['sort']
|
|
122
|
-
viewer: HydrateCtx['viewer']
|
|
123
|
-
threadTagsBumpDown: readonly string[]
|
|
124
|
-
threadTagsHide: readonly string[]
|
|
125
|
-
visibilityTagRankPrefix: string
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** This function mutates the tree parameter. */
|
|
129
|
-
function sortTrimThreadTree(
|
|
130
|
-
n: ThreadTree,
|
|
131
|
-
opts: SortTrimFlattenOptions,
|
|
132
|
-
): ThreadTree {
|
|
133
|
-
if (!isNodeWithReplies(n)) {
|
|
134
|
-
return n
|
|
135
|
-
}
|
|
136
|
-
const node: ThreadNodeWithReplies = n
|
|
137
|
-
|
|
138
|
-
if (node.replies) {
|
|
139
|
-
node.replies.sort((an: ThreadTree, bn: ThreadTree) => {
|
|
140
|
-
if (!isPostNode(an)) {
|
|
141
|
-
return 1
|
|
142
|
-
}
|
|
143
|
-
if (!isPostNode(bn)) {
|
|
144
|
-
return -1
|
|
145
|
-
}
|
|
146
|
-
const aNode: ThreadMaybeOtherPostNode = an
|
|
147
|
-
const bNode: ThreadMaybeOtherPostNode = bn
|
|
148
|
-
|
|
149
|
-
// First applies bumping.
|
|
150
|
-
const bump = applyBumping(aNode, bNode, opts)
|
|
151
|
-
if (bump !== null) {
|
|
152
|
-
return bump
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Then applies sorting.
|
|
156
|
-
return applySorting(aNode, bNode, opts)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
// Trimming: after sorting, apply branching factor to all levels of replies except the anchor direct replies.
|
|
160
|
-
if (node.item.depth !== 0) {
|
|
161
|
-
node.replies = node.replies.slice(0, opts.branchingFactor)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
node.replies.forEach((reply) => sortTrimThreadTree(reply, opts))
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return node
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function applyBumping(
|
|
171
|
-
aNode: ThreadMaybeOtherPostNode,
|
|
172
|
-
bNode: ThreadMaybeOtherPostNode,
|
|
173
|
-
opts: SortTrimFlattenOptions,
|
|
174
|
-
): number | null {
|
|
175
|
-
if (!isPostNode(aNode)) {
|
|
176
|
-
return null
|
|
177
|
-
}
|
|
178
|
-
if (!isPostNode(bNode)) {
|
|
179
|
-
return null
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const { opDid, viewer, threadTagsBumpDown, threadTagsHide } = opts
|
|
183
|
-
|
|
184
|
-
type BumpDirection = 'up' | 'down'
|
|
185
|
-
type BumpPredicateFn = (i: ThreadMaybeOtherPostNode) => boolean
|
|
186
|
-
|
|
187
|
-
const maybeBump = (
|
|
188
|
-
bump: BumpDirection,
|
|
189
|
-
predicateFn: BumpPredicateFn,
|
|
190
|
-
): number | null => {
|
|
191
|
-
const aPredicate = predicateFn(aNode)
|
|
192
|
-
const bPredicate = predicateFn(bNode)
|
|
193
|
-
if (aPredicate && bPredicate) {
|
|
194
|
-
return applySorting(aNode, bNode, opts)
|
|
195
|
-
} else if (aPredicate) {
|
|
196
|
-
return bump === 'up' ? -1 : 1
|
|
197
|
-
} else if (bPredicate) {
|
|
198
|
-
return bump === 'up' ? 1 : -1
|
|
199
|
-
}
|
|
200
|
-
return null
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// The order of the bumps determines the priority with which they are applied.
|
|
204
|
-
// Bumps-up applied first make the item appear higher in the list than later bumps-up.
|
|
205
|
-
// Bumps-down applied first make the item appear lower in the list than later bumps-down.
|
|
206
|
-
const bumps: [BumpDirection, BumpPredicateFn][] = [
|
|
207
|
-
/*
|
|
208
|
-
General bumps.
|
|
209
|
-
*/
|
|
210
|
-
// OP replies.
|
|
211
|
-
['up', (i) => i.item.value.post.author.did === opDid],
|
|
212
|
-
// Viewer replies.
|
|
213
|
-
['up', (i) => i.item.value.post.author.did === viewer],
|
|
214
|
-
|
|
215
|
-
/*
|
|
216
|
-
Bumps within visible replies.
|
|
217
|
-
*/
|
|
218
|
-
// Followers posts.
|
|
219
|
-
[
|
|
220
|
-
'up',
|
|
221
|
-
(i) => i.type === 'post' && !!i.item.value.post.author.viewer?.following,
|
|
222
|
-
],
|
|
223
|
-
// Bump-down tags.
|
|
224
|
-
[
|
|
225
|
-
'down',
|
|
226
|
-
(i) => i.type === 'post' && threadTagsBumpDown.some((t) => i.tags.has(t)),
|
|
227
|
-
],
|
|
228
|
-
|
|
229
|
-
/*
|
|
230
|
-
Bumps within hidden replies.
|
|
231
|
-
This determines the order of hidden replies:
|
|
232
|
-
1. hidden by threadgate.
|
|
233
|
-
2. hidden by tags.
|
|
234
|
-
3. muted by viewer.
|
|
235
|
-
*/
|
|
236
|
-
// Muted account by the viewer.
|
|
237
|
-
['down', (i) => i.type === 'hiddenPost' && i.item.value.mutedByViewer],
|
|
238
|
-
// Hidden by tags.
|
|
239
|
-
[
|
|
240
|
-
'down',
|
|
241
|
-
(i) =>
|
|
242
|
-
i.type === 'hiddenPost' && threadTagsHide.some((t) => i.tags.has(t)),
|
|
243
|
-
],
|
|
244
|
-
// Hidden by threadgate.
|
|
245
|
-
['down', (i) => i.type === 'hiddenPost' && i.item.value.hiddenByThreadgate],
|
|
246
|
-
]
|
|
247
|
-
|
|
248
|
-
for (const [bump, predicateFn] of bumps) {
|
|
249
|
-
const bumpResult = maybeBump(bump, predicateFn)
|
|
250
|
-
if (bumpResult !== null) {
|
|
251
|
-
return bumpResult
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return null
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function applySorting(
|
|
259
|
-
aNode: ThreadMaybeOtherPostNode,
|
|
260
|
-
bNode: ThreadMaybeOtherPostNode,
|
|
261
|
-
opts: SortTrimFlattenOptions,
|
|
262
|
-
): number {
|
|
263
|
-
const a = aNode.item.value
|
|
264
|
-
const b = bNode.item.value
|
|
265
|
-
|
|
266
|
-
// Only customize sort for visible posts.
|
|
267
|
-
if (aNode.type === 'post' && bNode.type === 'post') {
|
|
268
|
-
const { sort } = opts
|
|
269
|
-
|
|
270
|
-
if (sort === 'oldest') {
|
|
271
|
-
return a.post.indexedAt.localeCompare(b.post.indexedAt)
|
|
272
|
-
}
|
|
273
|
-
if (sort === 'top') {
|
|
274
|
-
const aLikes = a.post.likeCount ?? 0
|
|
275
|
-
const bLikes = b.post.likeCount ?? 0
|
|
276
|
-
const aTop = topSortValue(aLikes, aNode.hasOPLike)
|
|
277
|
-
const bTop = topSortValue(bLikes, bNode.hasOPLike)
|
|
278
|
-
if (aTop !== bTop) {
|
|
279
|
-
return bTop - aTop
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Fallback to newest.
|
|
285
|
-
return b.post.indexedAt.localeCompare(a.post.indexedAt)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function topSortValue(likeCount: number, hasOPLike: boolean): number {
|
|
289
|
-
return Math.log(3 + likeCount) * (hasOPLike ? 1.45 : 1.0)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function flattenTree(tree: ThreadTree) {
|
|
293
|
-
return [
|
|
294
|
-
// All parents above.
|
|
295
|
-
...Array.from(
|
|
296
|
-
flattenInDirection({
|
|
297
|
-
tree,
|
|
298
|
-
direction: 'up',
|
|
299
|
-
}),
|
|
300
|
-
),
|
|
301
|
-
|
|
302
|
-
// The anchor.
|
|
303
|
-
// In the case of hidden replies, the anchor item itself is undefined.
|
|
304
|
-
...(tree.item.value ? [tree.item] : []),
|
|
305
|
-
|
|
306
|
-
// All replies below.
|
|
307
|
-
...Array.from(
|
|
308
|
-
flattenInDirection({
|
|
309
|
-
tree,
|
|
310
|
-
direction: 'down',
|
|
311
|
-
}),
|
|
312
|
-
),
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function* flattenInDirection({
|
|
317
|
-
tree,
|
|
318
|
-
direction,
|
|
319
|
-
}: {
|
|
320
|
-
tree: ThreadTree
|
|
321
|
-
direction: 'up' | 'down'
|
|
322
|
-
}) {
|
|
323
|
-
if (tree.type === 'noUnauthenticated') {
|
|
324
|
-
if (direction === 'up') {
|
|
325
|
-
if (tree.parent) {
|
|
326
|
-
// Unfold all parents above.
|
|
327
|
-
yield* flattenTree(tree.parent)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (tree.type === 'post') {
|
|
333
|
-
if (direction === 'up') {
|
|
334
|
-
if (tree.parent) {
|
|
335
|
-
// Unfold all parents above.
|
|
336
|
-
yield* flattenTree(tree.parent)
|
|
337
|
-
}
|
|
338
|
-
} else {
|
|
339
|
-
// Unfold all replies below.
|
|
340
|
-
if (tree.replies?.length) {
|
|
341
|
-
for (const reply of tree.replies) {
|
|
342
|
-
yield* flattenTree(reply)
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// For the first level of hidden replies, the items are undefined.
|
|
349
|
-
if (tree.type === 'hiddenAnchor' || tree.type === 'hiddenPost') {
|
|
350
|
-
if (direction === 'down') {
|
|
351
|
-
// Unfold all replies below.
|
|
352
|
-
if (tree.replies?.length) {
|
|
353
|
-
for (const reply of tree.replies) {
|
|
354
|
-
yield* flattenTree(reply)
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export function sortTrimThreadTreeExploration(
|
|
362
|
-
n: ThreadTree,
|
|
363
|
-
opts: SortTrimFlattenOptions,
|
|
364
|
-
): ThreadTree {
|
|
365
|
-
if (!isNodeWithReplies(n)) {
|
|
366
|
-
return n
|
|
367
|
-
}
|
|
368
|
-
const node: ThreadNodeWithReplies = n
|
|
369
|
-
|
|
370
|
-
if (node.replies) {
|
|
371
|
-
node.replies.sort((an: ThreadTree, bn: ThreadTree) => {
|
|
372
|
-
if (!isPostNode(an)) {
|
|
373
|
-
return 1
|
|
374
|
-
}
|
|
375
|
-
if (!isPostNode(bn)) {
|
|
376
|
-
return -1
|
|
377
|
-
}
|
|
378
|
-
const aNode: ThreadMaybeOtherPostNode = an
|
|
379
|
-
const bNode: ThreadMaybeOtherPostNode = bn
|
|
380
|
-
|
|
381
|
-
// First applies bumping.
|
|
382
|
-
const bump = applyBumpingExploration(aNode, bNode, opts)
|
|
383
|
-
if (bump !== null) {
|
|
384
|
-
return bump
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Then applies sorting.
|
|
388
|
-
return applySortingExploration(aNode, bNode, opts)
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
// Trimming: after sorting, apply branching factor to all levels of replies except the anchor direct replies.
|
|
392
|
-
if (node.item.depth !== 0) {
|
|
393
|
-
node.replies = node.replies.slice(0, opts.branchingFactor)
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
node.replies.forEach((reply) => sortTrimThreadTreeExploration(reply, opts))
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return node
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function applyBumpingExploration(
|
|
403
|
-
aNode: ThreadMaybeOtherPostNode,
|
|
404
|
-
bNode: ThreadMaybeOtherPostNode,
|
|
405
|
-
opts: SortTrimFlattenOptions,
|
|
406
|
-
): number | null {
|
|
407
|
-
if (!isPostNode(aNode)) {
|
|
408
|
-
return null
|
|
409
|
-
}
|
|
410
|
-
if (!isPostNode(bNode)) {
|
|
411
|
-
return null
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const { opDid, viewer } = opts
|
|
415
|
-
|
|
416
|
-
type BumpDirection = 'up' | 'down'
|
|
417
|
-
type BumpPredicateFn = (i: ThreadMaybeOtherPostNode) => boolean
|
|
418
|
-
|
|
419
|
-
const maybeBump = (
|
|
420
|
-
bump: BumpDirection,
|
|
421
|
-
predicateFn: BumpPredicateFn,
|
|
422
|
-
): number | null => {
|
|
423
|
-
const aPredicate = predicateFn(aNode)
|
|
424
|
-
const bPredicate = predicateFn(bNode)
|
|
425
|
-
if (aPredicate && bPredicate) {
|
|
426
|
-
return applySortingExploration(aNode, bNode, opts)
|
|
427
|
-
} else if (aPredicate) {
|
|
428
|
-
return bump === 'up' ? -1 : 1
|
|
429
|
-
} else if (bPredicate) {
|
|
430
|
-
return bump === 'up' ? 1 : -1
|
|
431
|
-
}
|
|
432
|
-
return null
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// The order of the bumps determines the priority with which they are applied.
|
|
436
|
-
// Bumps-up applied first make the item appear higher in the list than later bumps-up.
|
|
437
|
-
// Bumps-down applied first make the item appear lower in the list than later bumps-down.
|
|
438
|
-
const bumps: [BumpDirection, BumpPredicateFn][] = [
|
|
439
|
-
/*
|
|
440
|
-
General bumps.
|
|
441
|
-
*/
|
|
442
|
-
// OP replies.
|
|
443
|
-
['up', (i) => i.item.value.post.author.did === opDid],
|
|
444
|
-
// Viewer replies.
|
|
445
|
-
['up', (i) => i.item.value.post.author.did === viewer],
|
|
446
|
-
]
|
|
447
|
-
|
|
448
|
-
for (const [bump, predicateFn] of bumps) {
|
|
449
|
-
const bumpResult = maybeBump(bump, predicateFn)
|
|
450
|
-
if (bumpResult !== null) {
|
|
451
|
-
return bumpResult
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return null
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
function applySortingExploration(
|
|
459
|
-
aNode: ThreadMaybeOtherPostNode,
|
|
460
|
-
bNode: ThreadMaybeOtherPostNode,
|
|
461
|
-
opts: SortTrimFlattenOptions,
|
|
462
|
-
): number {
|
|
463
|
-
const { visibilityTagRankPrefix: rp } = opts
|
|
464
|
-
|
|
465
|
-
const a = aNode.item.value
|
|
466
|
-
const ar = !rp ? 0 : parseRankFromTag(rp, findRankTag(aNode.tags, rp))
|
|
467
|
-
const b = bNode.item.value
|
|
468
|
-
const br = !rp ? 0 : parseRankFromTag(rp, findRankTag(bNode.tags, rp))
|
|
469
|
-
|
|
470
|
-
// Only customize sort for visible posts.
|
|
471
|
-
if (aNode.type === 'post' && bNode.type === 'post') {
|
|
472
|
-
const { sort } = opts
|
|
473
|
-
|
|
474
|
-
if (sort === 'oldest') {
|
|
475
|
-
return a.post.indexedAt.localeCompare(b.post.indexedAt)
|
|
476
|
-
}
|
|
477
|
-
if (sort === 'top') {
|
|
478
|
-
const aLikes = a.post.likeCount ?? 0
|
|
479
|
-
const bLikes = b.post.likeCount ?? 0
|
|
480
|
-
const aTop = topSortValue(aLikes, aNode.hasOPLike)
|
|
481
|
-
const bTop = topSortValue(bLikes, bNode.hasOPLike)
|
|
482
|
-
const aRank = aTop + ar
|
|
483
|
-
const bRank = bTop + br
|
|
484
|
-
if (aRank !== bRank) {
|
|
485
|
-
return bRank - aRank
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Fallback to newest.
|
|
491
|
-
return b.post.indexedAt.localeCompare(a.post.indexedAt)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function findRankTag(tags: Set<string>, prefix: string) {
|
|
495
|
-
return Array.from(tags.values()).find((tag) => tag.startsWith(prefix))
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function parseRankFromTag(prefix: string, tag?: string) {
|
|
499
|
-
if (!tag) return 0
|
|
500
|
-
|
|
501
|
-
try {
|
|
502
|
-
const rank = parseInt(tag.slice(prefix.length), 10)
|
|
503
|
-
if (typeof rank !== 'number' || isNaN(rank)) {
|
|
504
|
-
return 0
|
|
505
|
-
}
|
|
506
|
-
return rank
|
|
507
|
-
} catch {
|
|
508
|
-
return 0
|
|
509
|
-
}
|
|
510
|
-
}
|
package/src/views/types.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { app, chat, com, site } from '../lexicons/index.js'
|
|
2
|
-
|
|
3
|
-
// app.bsky.actor
|
|
4
|
-
|
|
5
|
-
export type ProfileRecord = app.bsky.actor.profile.Main
|
|
6
|
-
export const isProfileRecordType = app.bsky.actor.profile.$isTypeOf
|
|
7
|
-
|
|
8
|
-
export type ProfileViewer = app.bsky.actor.defs.ViewerState
|
|
9
|
-
export type KnownFollowers = app.bsky.actor.defs.KnownFollowers
|
|
10
|
-
export type ProfileAssociatedActivitySubscription =
|
|
11
|
-
app.bsky.actor.defs.ProfileAssociatedActivitySubscription
|
|
12
|
-
export type ProfileAssociatedChat = app.bsky.actor.defs.ProfileAssociatedChat
|
|
13
|
-
export type ProfileView = app.bsky.actor.defs.ProfileView
|
|
14
|
-
export type ProfileViewBasic = app.bsky.actor.defs.ProfileViewBasic
|
|
15
|
-
export type ProfileViewDetailed = app.bsky.actor.defs.ProfileViewDetailed
|
|
16
|
-
export type StatusView = app.bsky.actor.defs.StatusView
|
|
17
|
-
export type VerificationState = app.bsky.actor.defs.VerificationState
|
|
18
|
-
export type VerificationView = app.bsky.actor.defs.VerificationView
|
|
19
|
-
|
|
20
|
-
export type StatusRecord = app.bsky.actor.status.Main
|
|
21
|
-
|
|
22
|
-
// app.bsky.bookmark
|
|
23
|
-
|
|
24
|
-
export type BookmarkView = app.bsky.bookmark.defs.BookmarkView
|
|
25
|
-
|
|
26
|
-
// app.bsky.embed
|
|
27
|
-
|
|
28
|
-
export const isImagesEmbedType = app.bsky.embed.images.$isTypeOf
|
|
29
|
-
export type ImagesEmbed = app.bsky.embed.images.Main
|
|
30
|
-
export type ImagesEmbedView = app.bsky.embed.images.View
|
|
31
|
-
|
|
32
|
-
export const isVideoEmbedType = app.bsky.embed.video.$isTypeOf
|
|
33
|
-
export type VideoEmbed = app.bsky.embed.video.Main
|
|
34
|
-
export type VideoEmbedView = app.bsky.embed.video.View
|
|
35
|
-
|
|
36
|
-
export const isGalleryEmbedType = app.bsky.embed.gallery.$isTypeOf
|
|
37
|
-
export type GalleryEmbed = app.bsky.embed.gallery.Main
|
|
38
|
-
export type GalleryEmbedView = app.bsky.embed.gallery.View
|
|
39
|
-
export const isGalleryImageEmbedType = app.bsky.embed.gallery.image.$isTypeOf
|
|
40
|
-
export type GalleryImageEmbed = app.bsky.embed.gallery.Image
|
|
41
|
-
export type GalleryImageEmbedView = app.bsky.embed.gallery.ViewImage
|
|
42
|
-
|
|
43
|
-
export const isExternalEmbedType = app.bsky.embed.external.$isTypeOf
|
|
44
|
-
export type ExternalEmbed = app.bsky.embed.external.Main
|
|
45
|
-
export type ExternalEmbedView = app.bsky.embed.external.View
|
|
46
|
-
export type ExternalEmbedSourceView = app.bsky.embed.external.ViewExternalSource
|
|
47
|
-
export type ExternalEmbedSourceThemeView =
|
|
48
|
-
app.bsky.embed.external.ViewExternalSourceTheme
|
|
49
|
-
export type ExternalEmbedColorRgb = app.bsky.embed.external.ColorRgb
|
|
50
|
-
|
|
51
|
-
export const isRecordEmbedType = app.bsky.embed.record.$isTypeOf
|
|
52
|
-
export type RecordEmbed = app.bsky.embed.record.Main
|
|
53
|
-
export type RecordEmbedView = app.bsky.embed.record.View
|
|
54
|
-
export type EmbedBlocked = app.bsky.embed.record.ViewBlocked
|
|
55
|
-
export type EmbedDetached = app.bsky.embed.record.ViewDetached
|
|
56
|
-
export type EmbedNotFound = app.bsky.embed.record.ViewNotFound
|
|
57
|
-
export type PostEmbedView = app.bsky.embed.record.ViewRecord
|
|
58
|
-
|
|
59
|
-
export const isRecordWithMediaType = app.bsky.embed.recordWithMedia.$isTypeOf
|
|
60
|
-
export type RecordWithMedia = app.bsky.embed.recordWithMedia.Main
|
|
61
|
-
export type RecordWithMediaView = app.bsky.embed.recordWithMedia.View
|
|
62
|
-
export type RecordWithMediaEmbedView = app.bsky.embed.recordWithMedia.View
|
|
63
|
-
|
|
64
|
-
export type Embed =
|
|
65
|
-
| ImagesEmbed
|
|
66
|
-
| VideoEmbed
|
|
67
|
-
| GalleryEmbed
|
|
68
|
-
| ExternalEmbed
|
|
69
|
-
| RecordEmbed
|
|
70
|
-
| RecordWithMedia
|
|
71
|
-
|
|
72
|
-
export type EmbedView =
|
|
73
|
-
| ImagesEmbedView
|
|
74
|
-
| VideoEmbedView
|
|
75
|
-
| GalleryEmbedView
|
|
76
|
-
| ExternalEmbedView
|
|
77
|
-
| RecordEmbedView
|
|
78
|
-
| RecordWithMediaView
|
|
79
|
-
|
|
80
|
-
export type MaybePostView = PostView | NotFoundPost | BlockedPost
|
|
81
|
-
|
|
82
|
-
export type RecordEmbedViewInternal =
|
|
83
|
-
| PostEmbedView
|
|
84
|
-
| GeneratorView
|
|
85
|
-
| ListView
|
|
86
|
-
| LabelerView
|
|
87
|
-
| StarterPackViewBasic
|
|
88
|
-
|
|
89
|
-
// app.bsky.feed
|
|
90
|
-
|
|
91
|
-
export type LikeRecord = app.bsky.feed.like.Main
|
|
92
|
-
export type RepostRecord = app.bsky.feed.repost.Main
|
|
93
|
-
|
|
94
|
-
export type PostRecord = app.bsky.feed.post.Main
|
|
95
|
-
export const isPostRecordType = app.bsky.feed.post.$isTypeOf
|
|
96
|
-
|
|
97
|
-
export type PostgateRecord = app.bsky.feed.postgate.Main
|
|
98
|
-
export const isPostgateDisableRuleType =
|
|
99
|
-
app.bsky.feed.postgate.disableRule.$isTypeOf
|
|
100
|
-
|
|
101
|
-
export type FeedViewPost = app.bsky.feed.defs.FeedViewPost
|
|
102
|
-
export type ReasonPin = app.bsky.feed.defs.ReasonPin
|
|
103
|
-
export type ReasonRepost = app.bsky.feed.defs.ReasonRepost
|
|
104
|
-
export type ReplyRef = app.bsky.feed.defs.ReplyRef
|
|
105
|
-
export type PostReplyRef = app.bsky.feed.post.ReplyRef
|
|
106
|
-
export type ThreadViewPost = app.bsky.feed.defs.ThreadViewPost
|
|
107
|
-
export type ThreadgateView = app.bsky.feed.defs.ThreadgateView
|
|
108
|
-
export type BlockedPost = app.bsky.feed.defs.BlockedPost
|
|
109
|
-
export type GeneratorView = app.bsky.feed.defs.GeneratorView
|
|
110
|
-
export type NotFoundPost = app.bsky.feed.defs.NotFoundPost
|
|
111
|
-
export type PostView = app.bsky.feed.defs.PostView
|
|
112
|
-
export const isPostViewType = app.bsky.feed.defs.postView.$isTypeOf
|
|
113
|
-
|
|
114
|
-
export type GateRecord = app.bsky.feed.threadgate.Main
|
|
115
|
-
export const isFollowerRuleType =
|
|
116
|
-
app.bsky.feed.threadgate.followerRule.$isTypeOf
|
|
117
|
-
export const isFollowingRuleType =
|
|
118
|
-
app.bsky.feed.threadgate.followingRule.$isTypeOf
|
|
119
|
-
export const isListRuleType = app.bsky.feed.threadgate.listRule.$isTypeOf
|
|
120
|
-
export const isMentionRuleType = app.bsky.feed.threadgate.mentionRule.$isTypeOf
|
|
121
|
-
|
|
122
|
-
export type FeedGenRecord = app.bsky.feed.generator.Main
|
|
123
|
-
|
|
124
|
-
// app.bsky.graph
|
|
125
|
-
|
|
126
|
-
export type BlockRecord = app.bsky.graph.block.Main
|
|
127
|
-
export type FollowRecord = app.bsky.graph.follow.Main
|
|
128
|
-
export type ListItemRecord = app.bsky.graph.listitem.Main
|
|
129
|
-
export type ListItemView = app.bsky.graph.defs.ListItemView
|
|
130
|
-
export type ListRecord = app.bsky.graph.list.Main
|
|
131
|
-
export type ListView = app.bsky.graph.defs.ListView
|
|
132
|
-
export type ListViewBasic = app.bsky.graph.defs.ListViewBasic
|
|
133
|
-
export type StarterPackRecord = app.bsky.graph.starterpack.Main
|
|
134
|
-
export type StarterPackView = app.bsky.graph.defs.StarterPackView
|
|
135
|
-
export type StarterPackViewBasic = app.bsky.graph.defs.StarterPackViewBasic
|
|
136
|
-
export type VerificationRecord = app.bsky.graph.verification.Main
|
|
137
|
-
|
|
138
|
-
// app.bsky.labeler
|
|
139
|
-
|
|
140
|
-
export type LabelerRecord = app.bsky.labeler.service.Main
|
|
141
|
-
export const isLabelerRecordType = app.bsky.labeler.service.$isTypeOf
|
|
142
|
-
export type LabelerView = app.bsky.labeler.defs.LabelerView
|
|
143
|
-
export type LabelerViewDetailed = app.bsky.labeler.defs.LabelerViewDetailed
|
|
144
|
-
|
|
145
|
-
// app.bsky.notification
|
|
146
|
-
|
|
147
|
-
export type NotificationDeclarationRecord =
|
|
148
|
-
app.bsky.notification.declaration.Main
|
|
149
|
-
export type ActivitySubscription =
|
|
150
|
-
app.bsky.notification.defs.ActivitySubscription
|
|
151
|
-
export type NotificationRecordDeleted = app.bsky.notification.defs.RecordDeleted
|
|
152
|
-
export type NotificationView =
|
|
153
|
-
app.bsky.notification.listNotifications.Notification
|
|
154
|
-
|
|
155
|
-
// app.bsky.richtext
|
|
156
|
-
|
|
157
|
-
export const isMentionFacetType = app.bsky.richtext.facet.mention.$isTypeOf
|
|
158
|
-
|
|
159
|
-
// app.bsky.unspecced
|
|
160
|
-
|
|
161
|
-
export type ThreadItemBlocked = app.bsky.unspecced.defs.ThreadItemBlocked
|
|
162
|
-
export type ThreadItemNoUnauthenticated =
|
|
163
|
-
app.bsky.unspecced.defs.ThreadItemNoUnauthenticated
|
|
164
|
-
export type ThreadItemNotFound = app.bsky.unspecced.defs.ThreadItemNotFound
|
|
165
|
-
export type ThreadItemPost = app.bsky.unspecced.defs.ThreadItemPost
|
|
166
|
-
|
|
167
|
-
export type ThreadOtherItem = app.bsky.unspecced.getPostThreadOtherV2.ThreadItem
|
|
168
|
-
export type GetPostThreadV2QueryParams =
|
|
169
|
-
app.bsky.unspecced.getPostThreadV2.$Params
|
|
170
|
-
export type ThreadItem = app.bsky.unspecced.getPostThreadV2.ThreadItem
|
|
171
|
-
|
|
172
|
-
// chat.bsky.actor
|
|
173
|
-
|
|
174
|
-
export type ChatDeclarationRecord = chat.bsky.actor.declaration.Main
|
|
175
|
-
|
|
176
|
-
// com.atproto.label
|
|
177
|
-
|
|
178
|
-
export type Label = com.atproto.label.defs.Label
|
|
179
|
-
export const isSelfLabelsType = com.atproto.label.defs.selfLabels.$isTypeOf
|
|
180
|
-
|
|
181
|
-
// com.atproto.label
|
|
182
|
-
|
|
183
|
-
export type StrongRef = com.atproto.repo.strongRef.Main
|
|
184
|
-
export const validateStrongRef = com.atproto.repo.strongRef.$safeValidate
|
|
185
|
-
|
|
186
|
-
// com.germnetwork.declaration
|
|
187
|
-
|
|
188
|
-
export type GermDeclarationRecord = com.germnetwork.declaration.Main
|
|
189
|
-
|
|
190
|
-
// site.standard
|
|
191
|
-
|
|
192
|
-
export type SiteStandardDocumentRecord = site.standard.document.Main
|
|
193
|
-
export type SiteStandardPublicationRecord = site.standard.publication.Main
|