@atproto/api 0.4.3 → 0.5.0

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 (295) hide show
  1. package/README.md +81 -0
  2. package/definitions/labels.json +212 -0
  3. package/definitions/locale/en/label-groups.json +38 -0
  4. package/definitions/locale/en/labels.json +366 -0
  5. package/definitions/locale/en/proposed-label-groups.json +38 -0
  6. package/definitions/locale/en/proposed-labels.json +632 -0
  7. package/definitions/moderation-behaviors.d.ts +48 -0
  8. package/definitions/post-moderation-behaviors.json +879 -0
  9. package/definitions/profile-moderation-behaviors.json +447 -0
  10. package/definitions/proposed-labels.json +326 -0
  11. package/dist/client/index.d.ts +3 -0
  12. package/dist/client/lexicons.d.ts +41 -1
  13. package/dist/client/types/app/bsky/actor/updateProfile.d.ts +3 -10
  14. package/dist/client/types/app/bsky/{feed/getBookmarkedFeeds.d.ts → graph/getListBlocks.d.ts} +2 -2
  15. package/dist/client/types/app/bsky/graph/listblock.d.ts +8 -0
  16. package/dist/client/types/app/bsky/{feed/unbookmarkFeed.d.ts → graph/subscribeMuteList.d.ts} +1 -1
  17. package/dist/client/types/app/bsky/{feed/bookmarkFeed.d.ts → graph/unsubscribeMuteList.d.ts} +1 -1
  18. package/dist/{src/client/types/app/bsky/notification/updateSeen.d.ts → client/types/app/bsky/unspecced/applyLabels.d.ts} +2 -1
  19. package/dist/client/types/com/atproto/admin/defs.d.ts +2 -0
  20. package/dist/client/types/com/atproto/admin/disableAccountInvites.d.ts +1 -0
  21. package/dist/client/types/com/atproto/admin/enableAccountInvites.d.ts +1 -0
  22. package/dist/helpers/bsky.d.ts +20 -0
  23. package/dist/index.d.ts +4 -0
  24. package/dist/index.js +1417 -14
  25. package/dist/index.js.map +4 -4
  26. package/dist/mixins/bsky.d.ts +23 -0
  27. package/dist/moderation/accumulator.d.ts +14 -0
  28. package/dist/moderation/const/label-groups.d.ts +2 -0
  29. package/dist/moderation/const/labels.d.ts +2 -0
  30. package/dist/moderation/index.d.ts +44 -0
  31. package/dist/moderation/subjects/account.d.ts +3 -0
  32. package/dist/moderation/subjects/feed-generator.d.ts +2 -0
  33. package/dist/moderation/subjects/post.d.ts +2 -0
  34. package/dist/moderation/subjects/profile.d.ts +3 -0
  35. package/dist/moderation/subjects/quoted-post.d.ts +6 -0
  36. package/dist/moderation/subjects/user-list.d.ts +2 -0
  37. package/dist/moderation/types.d.ts +97 -0
  38. package/dist/moderation/util.d.ts +12 -0
  39. package/dist/rich-text/sanitize.d.ts +4 -0
  40. package/docs/labels.md +522 -0
  41. package/docs/moderation-behaviors/posts.md +1919 -0
  42. package/docs/moderation-behaviors/profiles.md +907 -0
  43. package/docs/moderation.md +144 -0
  44. package/package.json +6 -4
  45. package/scripts/code/label-groups.mjs +68 -0
  46. package/scripts/code/labels.mjs +68 -0
  47. package/scripts/docs/labels.mjs +164 -0
  48. package/scripts/docs/post-moderation-behaviors.mjs +122 -0
  49. package/scripts/docs/profile-moderation-behaviors.mjs +122 -0
  50. package/scripts/generate-code.mjs +4 -0
  51. package/scripts/generate-docs.mjs +5 -0
  52. package/src/client/index.ts +13 -0
  53. package/src/client/lexicons.ts +44 -2
  54. package/src/client/types/app/bsky/unspecced/applyLabels.ts +33 -0
  55. package/src/client/types/com/atproto/admin/defs.ts +2 -0
  56. package/src/client/types/com/atproto/admin/disableAccountInvites.ts +2 -0
  57. package/src/client/types/com/atproto/admin/enableAccountInvites.ts +2 -0
  58. package/src/client/types/com/atproto/moderation/defs.ts +1 -1
  59. package/src/index.ts +4 -0
  60. package/src/moderation/accumulator.ts +181 -0
  61. package/src/moderation/const/label-groups.ts +143 -0
  62. package/src/moderation/const/labels.ts +798 -0
  63. package/src/moderation/index.ts +343 -0
  64. package/src/moderation/subjects/account.ts +40 -0
  65. package/src/moderation/subjects/feed-generator.ts +13 -0
  66. package/src/moderation/subjects/post.ts +23 -0
  67. package/src/moderation/subjects/profile.ts +31 -0
  68. package/src/moderation/subjects/quoted-post.ts +62 -0
  69. package/src/moderation/subjects/user-list.ts +13 -0
  70. package/src/moderation/types.ts +141 -0
  71. package/src/moderation/util.ts +98 -0
  72. package/tests/post-moderation.test.ts +46 -0
  73. package/tests/profile-moderation.test.ts +46 -0
  74. package/tests/util/index.ts +176 -0
  75. package/tests/util/moderation-behavior.ts +180 -0
  76. package/dist/client/types/app/bsky/actor/searchActor.d.ts +0 -22
  77. package/dist/client/types/app/bsky/actor/searchActorTypeahead.d.ts +0 -20
  78. package/dist/client/types/com/atproto/admin/getInviteCodeUsage.d.ts +0 -29
  79. package/dist/client/types/com/atproto/repo/importRepo.d.ts +0 -19
  80. package/dist/client/types/com/atproto/repo/uploadRepo.d.ts +0 -19
  81. package/dist/client/types/com/atproto/server/getUserInviteCodes.d.ts +0 -31
  82. package/dist/src/client/index.d.ts +0 -462
  83. package/dist/src/client/lexicons.d.ts +0 -2910
  84. package/dist/src/client/schemas.d.ts +0 -17
  85. package/dist/src/client/types/app/bsky/actor/createScene.d.ts +0 -32
  86. package/dist/src/client/types/app/bsky/actor/getProfile.d.ts +0 -36
  87. package/dist/src/client/types/app/bsky/actor/getSuggestions.d.ts +0 -36
  88. package/dist/src/client/types/app/bsky/actor/profile.d.ts +0 -15
  89. package/dist/src/client/types/app/bsky/actor/ref.d.ts +0 -14
  90. package/dist/src/client/types/app/bsky/actor/search.d.ts +0 -32
  91. package/dist/src/client/types/app/bsky/actor/searchTypeahead.d.ts +0 -28
  92. package/dist/src/client/types/app/bsky/actor/updateProfile.d.ts +0 -48
  93. package/dist/src/client/types/app/bsky/badge.d.ts +0 -22
  94. package/dist/src/client/types/app/bsky/badgeAccept.d.ts +0 -11
  95. package/dist/src/client/types/app/bsky/badgeOffer.d.ts +0 -11
  96. package/dist/src/client/types/app/bsky/declaration.d.ts +0 -6
  97. package/dist/src/client/types/app/bsky/embed/external.d.ts +0 -26
  98. package/dist/src/client/types/app/bsky/embed/images.d.ts +0 -23
  99. package/dist/src/client/types/app/bsky/feed/embed.d.ts +0 -36
  100. package/dist/src/client/types/app/bsky/feed/feedViewPost.d.ts +0 -26
  101. package/dist/src/client/types/app/bsky/feed/getAuthorFeed.d.ts +0 -22
  102. package/dist/src/client/types/app/bsky/feed/getPostThread.d.ts +0 -43
  103. package/dist/src/client/types/app/bsky/feed/getRepostedBy.d.ts +0 -35
  104. package/dist/src/client/types/app/bsky/feed/getTimeline.d.ts +0 -22
  105. package/dist/src/client/types/app/bsky/feed/getVotes.d.ts +0 -33
  106. package/dist/src/client/types/app/bsky/feed/mediaEmbed.d.ts +0 -18
  107. package/dist/src/client/types/app/bsky/feed/post.d.ts +0 -54
  108. package/dist/src/client/types/app/bsky/feed/repost.d.ts +0 -6
  109. package/dist/src/client/types/app/bsky/feed/setVote.d.ts +0 -25
  110. package/dist/src/client/types/app/bsky/feed/trend.d.ts +0 -6
  111. package/dist/src/client/types/app/bsky/feed/vote.d.ts +0 -7
  112. package/dist/src/client/types/app/bsky/follow.d.ts +0 -9
  113. package/dist/src/client/types/app/bsky/getAuthorFeed.d.ts +0 -56
  114. package/dist/src/client/types/app/bsky/getBadgeMembers.d.ts +0 -29
  115. package/dist/src/client/types/app/bsky/getHomeFeed.d.ts +0 -56
  116. package/dist/src/client/types/app/bsky/getLikedBy.d.ts +0 -29
  117. package/dist/src/client/types/app/bsky/getNotificationCount.d.ts +0 -16
  118. package/dist/src/client/types/app/bsky/getNotifications.d.ts +0 -33
  119. package/dist/src/client/types/app/bsky/getPostThread.d.ts +0 -55
  120. package/dist/src/client/types/app/bsky/getProfile.d.ts +0 -26
  121. package/dist/src/client/types/app/bsky/getRepostedBy.d.ts +0 -29
  122. package/dist/src/client/types/app/bsky/getTimeline.d.ts +0 -56
  123. package/dist/src/client/types/app/bsky/getUserFollowers.d.ts +0 -31
  124. package/dist/src/client/types/app/bsky/getUserFollows.d.ts +0 -31
  125. package/dist/src/client/types/app/bsky/getUsersSearch.d.ts +0 -26
  126. package/dist/src/client/types/app/bsky/getUsersTypeahead.d.ts +0 -22
  127. package/dist/src/client/types/app/bsky/graph/assertCreator.d.ts +0 -1
  128. package/dist/src/client/types/app/bsky/graph/assertMember.d.ts +0 -1
  129. package/dist/src/client/types/app/bsky/graph/assertion.d.ts +0 -7
  130. package/dist/src/client/types/app/bsky/graph/confirmation.d.ts +0 -8
  131. package/dist/src/client/types/app/bsky/graph/follow.d.ts +0 -6
  132. package/dist/src/client/types/app/bsky/graph/getAssertions.d.ts +0 -43
  133. package/dist/src/client/types/app/bsky/graph/getFollowers.d.ts +0 -34
  134. package/dist/src/client/types/app/bsky/graph/getFollows.d.ts +0 -33
  135. package/dist/src/client/types/app/bsky/graph/getMembers.d.ts +0 -33
  136. package/dist/src/client/types/app/bsky/graph/getMemberships.d.ts +0 -33
  137. package/dist/src/client/types/app/bsky/invite.d.ts +0 -10
  138. package/dist/src/client/types/app/bsky/inviteAccept.d.ts +0 -14
  139. package/dist/src/client/types/app/bsky/like.d.ts +0 -10
  140. package/dist/src/client/types/app/bsky/mediaEmbed.d.ts +0 -15
  141. package/dist/src/client/types/app/bsky/notification/getCount.d.ts +0 -17
  142. package/dist/src/client/types/app/bsky/notification/list.d.ts +0 -32
  143. package/dist/src/client/types/app/bsky/post.d.ts +0 -23
  144. package/dist/src/client/types/app/bsky/postNotificationsSeen.d.ts +0 -20
  145. package/dist/src/client/types/app/bsky/profile.d.ts +0 -5
  146. package/dist/src/client/types/app/bsky/repost.d.ts +0 -10
  147. package/dist/src/client/types/app/bsky/system/actorScene.d.ts +0 -1
  148. package/dist/src/client/types/app/bsky/system/actorUser.d.ts +0 -1
  149. package/dist/src/client/types/app/bsky/system/declRef.d.ts +0 -5
  150. package/dist/src/client/types/app/bsky/system/declaration.d.ts +0 -4
  151. package/dist/src/client/types/app/bsky/updateProfile.d.ts +0 -23
  152. package/dist/src/client/types/com/atproto/account/create.d.ts +0 -41
  153. package/dist/src/client/types/com/atproto/account/createInviteCode.d.ts +0 -22
  154. package/dist/src/client/types/com/atproto/account/delete.d.ts +0 -13
  155. package/dist/src/client/types/com/atproto/account/get.d.ts +0 -12
  156. package/dist/src/client/types/com/atproto/account/requestPasswordReset.d.ts +0 -17
  157. package/dist/src/client/types/com/atproto/account/resetPassword.d.ts +0 -24
  158. package/dist/src/client/types/com/atproto/blob/upload.d.ts +0 -19
  159. package/dist/src/client/types/com/atproto/createAccount.d.ts +0 -40
  160. package/dist/src/client/types/com/atproto/createInviteCode.d.ts +0 -20
  161. package/dist/src/client/types/com/atproto/createSession.d.ts +0 -24
  162. package/dist/src/client/types/com/atproto/data/uploadFile.d.ts +0 -19
  163. package/dist/src/client/types/com/atproto/deleteAccount.d.ts +0 -20
  164. package/dist/src/client/types/com/atproto/deleteSession.d.ts +0 -17
  165. package/dist/src/client/types/com/atproto/getAccount.d.ts +0 -16
  166. package/dist/src/client/types/com/atproto/getAccountsConfig.d.ts +0 -17
  167. package/dist/src/client/types/com/atproto/getSession.d.ts +0 -17
  168. package/dist/src/client/types/com/atproto/handle/resolve.d.ts +0 -18
  169. package/dist/src/client/types/com/atproto/refreshSession.d.ts +0 -20
  170. package/dist/src/client/types/com/atproto/repo/batchWrite.d.ts +0 -39
  171. package/dist/src/client/types/com/atproto/repo/createRecord.d.ts +0 -26
  172. package/dist/src/client/types/com/atproto/repo/deleteRecord.d.ts +0 -19
  173. package/dist/src/client/types/com/atproto/repo/describe.d.ts +0 -22
  174. package/dist/src/client/types/com/atproto/repo/getRecord.d.ts +0 -23
  175. package/dist/src/client/types/com/atproto/repo/listRecords.d.ts +0 -30
  176. package/dist/src/client/types/com/atproto/repo/putRecord.d.ts +0 -27
  177. package/dist/src/client/types/com/atproto/repo/strongRef.d.ts +0 -5
  178. package/dist/src/client/types/com/atproto/repoBatchWrite.d.ts +0 -36
  179. package/dist/src/client/types/com/atproto/repoCreateRecord.d.ts +0 -24
  180. package/dist/src/client/types/com/atproto/repoDeleteRecord.d.ts +0 -18
  181. package/dist/src/client/types/com/atproto/repoDescribe.d.ts +0 -21
  182. package/dist/src/client/types/com/atproto/repoGetRecord.d.ts +0 -22
  183. package/dist/src/client/types/com/atproto/repoListRecords.d.ts +0 -27
  184. package/dist/src/client/types/com/atproto/repoPutRecord.d.ts +0 -25
  185. package/dist/src/client/types/com/atproto/requestAccountPasswordReset.d.ts +0 -19
  186. package/dist/src/client/types/com/atproto/resetAccountPassword.d.ts +0 -26
  187. package/dist/src/client/types/com/atproto/resolveHandle.d.ts +0 -17
  188. package/dist/src/client/types/com/atproto/resolveName.d.ts +0 -17
  189. package/dist/src/client/types/com/atproto/server/getAccountsConfig.d.ts +0 -24
  190. package/dist/src/client/types/com/atproto/session/create.d.ts +0 -26
  191. package/dist/src/client/types/com/atproto/session/delete.d.ts +0 -13
  192. package/dist/src/client/types/com/atproto/session/get.d.ts +0 -18
  193. package/dist/src/client/types/com/atproto/session/refresh.d.ts +0 -21
  194. package/dist/src/client/types/com/atproto/sync/getRepo.d.ts +0 -15
  195. package/dist/src/client/types/com/atproto/sync/getRoot.d.ts +0 -18
  196. package/dist/src/client/types/com/atproto/sync/updateRepo.d.ts +0 -15
  197. package/dist/src/client/types/com/atproto/syncGetRepo.d.ts +0 -15
  198. package/dist/src/client/types/com/atproto/syncGetRoot.d.ts +0 -17
  199. package/dist/src/client/types/com/atproto/syncUpdateRepo.d.ts +0 -15
  200. package/dist/src/index.d.ts +0 -4
  201. package/dist/src/schemas.d.ts +0 -19
  202. package/dist/src/session.d.ts +0 -42
  203. package/dist/src/types/app/bsky/acceptedBadge.d.ts +0 -10
  204. package/dist/src/types/app/bsky/badge.d.ts +0 -22
  205. package/dist/src/types/app/bsky/badgeAccept.d.ts +0 -11
  206. package/dist/src/types/app/bsky/badgeOffer.d.ts +0 -11
  207. package/dist/src/types/app/bsky/declaration.d.ts +0 -6
  208. package/dist/src/types/app/bsky/follow.d.ts +0 -9
  209. package/dist/src/types/app/bsky/getAuthorFeed.d.ts +0 -56
  210. package/dist/src/types/app/bsky/getBadgeMembers.d.ts +0 -29
  211. package/dist/src/types/app/bsky/getHomeFeed.d.ts +0 -56
  212. package/dist/src/types/app/bsky/getLikedBy.d.ts +0 -29
  213. package/dist/src/types/app/bsky/getNotificationCount.d.ts +0 -16
  214. package/dist/src/types/app/bsky/getNotifications.d.ts +0 -33
  215. package/dist/src/types/app/bsky/getPostThread.d.ts +0 -55
  216. package/dist/src/types/app/bsky/getProfile.d.ts +0 -42
  217. package/dist/src/types/app/bsky/getRepostedBy.d.ts +0 -29
  218. package/dist/src/types/app/bsky/getUserFollowers.d.ts +0 -31
  219. package/dist/src/types/app/bsky/getUserFollows.d.ts +0 -31
  220. package/dist/src/types/app/bsky/getUsersSearch.d.ts +0 -26
  221. package/dist/src/types/app/bsky/getUsersTypeahead.d.ts +0 -22
  222. package/dist/src/types/app/bsky/invite.d.ts +0 -10
  223. package/dist/src/types/app/bsky/inviteAccept.d.ts +0 -14
  224. package/dist/src/types/app/bsky/like.d.ts +0 -10
  225. package/dist/src/types/app/bsky/mediaEmbed.d.ts +0 -15
  226. package/dist/src/types/app/bsky/post.d.ts +0 -23
  227. package/dist/src/types/app/bsky/postNotificationsSeen.d.ts +0 -19
  228. package/dist/src/types/app/bsky/profile.d.ts +0 -11
  229. package/dist/src/types/app/bsky/repost.d.ts +0 -10
  230. package/dist/src/types/app/bsky/updateProfile.d.ts +0 -27
  231. package/dist/src/types/com/atproto/createAccount.d.ts +0 -39
  232. package/dist/src/types/com/atproto/createInviteCode.d.ts +0 -19
  233. package/dist/src/types/com/atproto/createSession.d.ts +0 -23
  234. package/dist/src/types/com/atproto/deleteAccount.d.ts +0 -19
  235. package/dist/src/types/com/atproto/deleteSession.d.ts +0 -16
  236. package/dist/src/types/com/atproto/getAccount.d.ts +0 -19
  237. package/dist/src/types/com/atproto/getAccountsConfig.d.ts +0 -17
  238. package/dist/src/types/com/atproto/getSession.d.ts +0 -17
  239. package/dist/src/types/com/atproto/refreshSession.d.ts +0 -19
  240. package/dist/src/types/com/atproto/repoBatchWrite.d.ts +0 -35
  241. package/dist/src/types/com/atproto/repoCreateRecord.d.ts +0 -23
  242. package/dist/src/types/com/atproto/repoDeleteRecord.d.ts +0 -15
  243. package/dist/src/types/com/atproto/repoDescribe.d.ts +0 -21
  244. package/dist/src/types/com/atproto/repoGetRecord.d.ts +0 -22
  245. package/dist/src/types/com/atproto/repoListRecords.d.ts +0 -27
  246. package/dist/src/types/com/atproto/repoPutRecord.d.ts +0 -24
  247. package/dist/src/types/com/atproto/requestAccountPasswordReset.d.ts +0 -18
  248. package/dist/src/types/com/atproto/resetAccountPassword.d.ts +0 -25
  249. package/dist/src/types/com/atproto/resolveName.d.ts +0 -17
  250. package/dist/src/types/com/atproto/syncGetRepo.d.ts +0 -15
  251. package/dist/src/types/com/atproto/syncGetRoot.d.ts +0 -17
  252. package/dist/src/types/com/atproto/syncUpdateRepo.d.ts +0 -14
  253. package/dist/src/types/todo/adx/createAccount.d.ts +0 -36
  254. package/dist/src/types/todo/adx/createInviteCode.d.ts +0 -19
  255. package/dist/src/types/todo/adx/createSession.d.ts +0 -22
  256. package/dist/src/types/todo/adx/deleteAccount.d.ts +0 -19
  257. package/dist/src/types/todo/adx/deleteSession.d.ts +0 -19
  258. package/dist/src/types/todo/adx/getAccount.d.ts +0 -19
  259. package/dist/src/types/todo/adx/getAccountsConfig.d.ts +0 -17
  260. package/dist/src/types/todo/adx/getSession.d.ts +0 -17
  261. package/dist/src/types/todo/adx/repoBatchWrite.d.ts +0 -34
  262. package/dist/src/types/todo/adx/repoCreateRecord.d.ts +0 -22
  263. package/dist/src/types/todo/adx/repoDeleteRecord.d.ts +0 -15
  264. package/dist/src/types/todo/adx/repoDescribe.d.ts +0 -21
  265. package/dist/src/types/todo/adx/repoGetRecord.d.ts +0 -20
  266. package/dist/src/types/todo/adx/repoListRecords.d.ts +0 -25
  267. package/dist/src/types/todo/adx/repoPutRecord.d.ts +0 -23
  268. package/dist/src/types/todo/adx/requestAccountPasswordReset.d.ts +0 -18
  269. package/dist/src/types/todo/adx/resetAccountPassword.d.ts +0 -25
  270. package/dist/src/types/todo/adx/resolveName.d.ts +0 -17
  271. package/dist/src/types/todo/adx/syncGetRepo.d.ts +0 -15
  272. package/dist/src/types/todo/adx/syncGetRoot.d.ts +0 -17
  273. package/dist/src/types/todo/adx/syncUpdateRepo.d.ts +0 -14
  274. package/dist/src/types/todo/social/badge.d.ts +0 -23
  275. package/dist/src/types/todo/social/follow.d.ts +0 -5
  276. package/dist/src/types/todo/social/getAuthorFeed.d.ts +0 -55
  277. package/dist/src/types/todo/social/getFeed.d.ts +0 -55
  278. package/dist/src/types/todo/social/getHomeFeed.d.ts +0 -55
  279. package/dist/src/types/todo/social/getLikedBy.d.ts +0 -26
  280. package/dist/src/types/todo/social/getNotificationCount.d.ts +0 -16
  281. package/dist/src/types/todo/social/getNotifications.d.ts +0 -31
  282. package/dist/src/types/todo/social/getPostThread.d.ts +0 -54
  283. package/dist/src/types/todo/social/getProfile.d.ts +0 -40
  284. package/dist/src/types/todo/social/getRepostedBy.d.ts +0 -26
  285. package/dist/src/types/todo/social/getUserFollowers.d.ts +0 -30
  286. package/dist/src/types/todo/social/getUserFollows.d.ts +0 -30
  287. package/dist/src/types/todo/social/like.d.ts +0 -5
  288. package/dist/src/types/todo/social/mediaEmbed.d.ts +0 -15
  289. package/dist/src/types/todo/social/post.d.ts +0 -18
  290. package/dist/src/types/todo/social/postNotificationsSeen.d.ts +0 -19
  291. package/dist/src/types/todo/social/profile.d.ts +0 -10
  292. package/dist/src/types/todo/social/repost.d.ts +0 -5
  293. package/dist/tsconfig.build.tsbuildinfo +0 -1
  294. package/tests/_util.ts +0 -26
  295. package/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,122 @@
1
+ import * as url from 'url'
2
+ import { readFileSync, writeFileSync } from 'fs'
3
+ import { join } from 'path'
4
+ import { stripIndents } from 'common-tags'
5
+
6
+ const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
7
+
8
+ const profileModerationBehaviorsDef = JSON.parse(
9
+ readFileSync(
10
+ join(
11
+ __dirname,
12
+ '..',
13
+ '..',
14
+ 'definitions',
15
+ 'profile-moderation-behaviors.json',
16
+ ),
17
+ 'utf8',
18
+ ),
19
+ )
20
+
21
+ writeFileSync(
22
+ join(__dirname, '..', '..', 'docs', 'moderation-behaviors', 'profiles.md'),
23
+ profiles(),
24
+ 'utf8',
25
+ )
26
+
27
+ function profiles() {
28
+ let lastTitle = 'NULL'
29
+ return stripIndents`
30
+ <!-- this doc is generated by ./scripts/docs/profile-moderation-behaviors.mjs -->
31
+
32
+ # Profile moderation behaviors
33
+
34
+ This document is a reference for the expected behaviors for a profile in the application based on some given scenarios. The <code>moderateProfile()</code> command condense down to the following yes or no decisions:
35
+
36
+ - <code>res.account.filter</code> Do not show the account in feeds.
37
+ - <code>res.account.blur</code> Put the account (in listings, when viewing) behind a warning cover.
38
+ - <code>res.account.noOverride</code> Do not allow the account's blur cover to be lifted.
39
+ - <code>res.account.alert</code> Add a warning to the account but do not cover it.
40
+ - <code>res.profile.blur</code> Put the profile details (handle, display name, bio) behind a warning cover.
41
+ - <code>res.profile.noOverride</code> Do not allow the profile's blur cover to be lifted.
42
+ - <code>res.profile.alert</code> Add a warning to the profile but do not cover it.
43
+ - <code>res.avatar.blur</code> Put the avatar behind a cover.
44
+ - <code>res.avatar.noOverride</code> Do not allow the avatars's blur cover to be lifted.
45
+ - <code>res.avatar.alert</code> Put a warning icon on the avatar.
46
+
47
+ Key:
48
+
49
+ - ❌ = Filter Content
50
+ - 🚫 = Blur (no-override)
51
+ - ✋ = Blur
52
+ - 🪧 = Alert
53
+
54
+ ## Scenarios
55
+
56
+ <table>
57
+ ${Array.from(Object.entries(profileModerationBehaviorsDef.scenarios))
58
+ .map(([title, scenario], i) => {
59
+ const str = `
60
+ ${title.indexOf(lastTitle) === -1 ? postTableHead() : ''}
61
+ ${scenarioSection(title, scenario)}
62
+ `
63
+ lastTitle = title.slice(0, 10)
64
+ return str
65
+ })
66
+ .join('\n\n')}
67
+ </table>
68
+ `
69
+ }
70
+
71
+ function postTableHead() {
72
+ return `<tr><th>Scenario</th><th>Filter</th><th>Account</th><th>Profile</td><th>Avatar</th></tr>`
73
+ }
74
+
75
+ function scenarioSection(title, scenario) {
76
+ return stripIndents`
77
+ <tr>
78
+ <td><strong>${title}</strong></td>
79
+ <td>
80
+ ${filter(scenario.behaviors.account?.filter)}
81
+ </td>
82
+ <td>
83
+ ${blur(
84
+ scenario.behaviors.account?.blur,
85
+ scenario.behaviors.account?.noOverride,
86
+ )}
87
+ ${alert(scenario.behaviors.account?.alert)}
88
+ </td>
89
+ <td>
90
+ ${blur(
91
+ scenario.behaviors.profile?.blur,
92
+ scenario.behaviors.profile?.noOverride,
93
+ )}
94
+ ${alert(scenario.behaviors.profile?.alert)}
95
+ </td>
96
+ <td>
97
+ ${blur(
98
+ scenario.behaviors.avatar?.blur,
99
+ scenario.behaviors.avatar?.noOverride,
100
+ )}
101
+ ${alert(scenario.behaviors.avatar?.alert)}
102
+ </td>
103
+ </tr>
104
+ `
105
+ }
106
+
107
+ function filter(val) {
108
+ return val ? '❌' : ''
109
+ }
110
+
111
+ function blur(val, noOverride) {
112
+ if (val) {
113
+ return noOverride ? '🚫' : '✋'
114
+ }
115
+ return ''
116
+ }
117
+
118
+ function alert(val) {
119
+ return val ? '🪧' : ''
120
+ }
121
+
122
+ export {}
@@ -0,0 +1,4 @@
1
+ import './code/labels.mjs'
2
+ import './code/label-groups.mjs'
3
+
4
+ export {}
@@ -0,0 +1,5 @@
1
+ import './docs/labels.mjs'
2
+ import './docs/post-moderation-behaviors.mjs'
3
+ import './docs/profile-moderation-behaviors.mjs'
4
+
5
+ export {}
@@ -122,6 +122,7 @@ import * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notificatio
122
122
  import * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
123
123
  import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
124
124
  import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
125
+ import * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
125
126
  import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
126
127
  import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
127
128
  import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
@@ -241,6 +242,7 @@ export * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notificatio
241
242
  export * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
242
243
  export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
243
244
  export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
245
+ export * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
244
246
  export * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
245
247
  export * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
246
248
  export * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
@@ -2036,6 +2038,17 @@ export class UnspeccedNS {
2036
2038
  this._service = service
2037
2039
  }
2038
2040
 
2041
+ applyLabels(
2042
+ data?: AppBskyUnspeccedApplyLabels.InputSchema,
2043
+ opts?: AppBskyUnspeccedApplyLabels.CallOptions,
2044
+ ): Promise<AppBskyUnspeccedApplyLabels.Response> {
2045
+ return this._service.xrpc
2046
+ .call('app.bsky.unspecced.applyLabels', opts?.qp, data, opts)
2047
+ .catch((e) => {
2048
+ throw AppBskyUnspeccedApplyLabels.toKnownErr(e)
2049
+ })
2050
+ }
2051
+
2039
2052
  getPopular(
2040
2053
  params?: AppBskyUnspeccedGetPopular.QueryParams,
2041
2054
  opts?: AppBskyUnspeccedGetPopular.CallOptions,
@@ -343,6 +343,9 @@ export const schemaDict = {
343
343
  invitesDisabled: {
344
344
  type: 'boolean',
345
345
  },
346
+ inviteNote: {
347
+ type: 'string',
348
+ },
346
349
  },
347
350
  },
348
351
  repoViewDetail: {
@@ -401,6 +404,9 @@ export const schemaDict = {
401
404
  invitesDisabled: {
402
405
  type: 'boolean',
403
406
  },
407
+ inviteNote: {
408
+ type: 'string',
409
+ },
404
410
  },
405
411
  },
406
412
  repoViewNotFound: {
@@ -530,7 +536,6 @@ export const schemaDict = {
530
536
  },
531
537
  moderation: {
532
538
  type: 'object',
533
- required: [],
534
539
  properties: {
535
540
  currentAction: {
536
541
  type: 'ref',
@@ -640,6 +645,11 @@ export const schemaDict = {
640
645
  type: 'string',
641
646
  format: 'did',
642
647
  },
648
+ note: {
649
+ type: 'string',
650
+ description:
651
+ 'Additionally add a note describing why the invites were disabled',
652
+ },
643
653
  },
644
654
  },
645
655
  },
@@ -694,6 +704,11 @@ export const schemaDict = {
694
704
  type: 'string',
695
705
  format: 'did',
696
706
  },
707
+ note: {
708
+ type: 'string',
709
+ description:
710
+ 'Additionally add a note describing why the invites were enabled',
711
+ },
697
712
  },
698
713
  },
699
714
  },
@@ -1652,7 +1667,7 @@ export const schemaDict = {
1652
1667
  },
1653
1668
  reasonSexual: {
1654
1669
  type: 'token',
1655
- description: 'Unwanted or mis-labeled sexual content',
1670
+ description: 'Unwanted or mislabeled sexual content',
1656
1671
  },
1657
1672
  reasonRude: {
1658
1673
  type: 'token',
@@ -6278,6 +6293,32 @@ export const schemaDict = {
6278
6293
  },
6279
6294
  },
6280
6295
  },
6296
+ AppBskyUnspeccedApplyLabels: {
6297
+ lexicon: 1,
6298
+ id: 'app.bsky.unspecced.applyLabels',
6299
+ defs: {
6300
+ main: {
6301
+ type: 'procedure',
6302
+ description: 'Allow a labeler to apply labels directly.',
6303
+ input: {
6304
+ encoding: 'application/json',
6305
+ schema: {
6306
+ type: 'object',
6307
+ required: ['labels'],
6308
+ properties: {
6309
+ labels: {
6310
+ type: 'array',
6311
+ items: {
6312
+ type: 'ref',
6313
+ ref: 'lex:com.atproto.label.defs#label',
6314
+ },
6315
+ },
6316
+ },
6317
+ },
6318
+ },
6319
+ },
6320
+ },
6321
+ },
6281
6322
  AppBskyUnspeccedGetPopular: {
6282
6323
  lexicon: 1,
6283
6324
  id: 'app.bsky.unspecced.getPopular',
@@ -6545,6 +6586,7 @@ export const ids = {
6545
6586
  'app.bsky.notification.listNotifications',
6546
6587
  AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
6547
6588
  AppBskyRichtextFacet: 'app.bsky.richtext.facet',
6589
+ AppBskyUnspeccedApplyLabels: 'app.bsky.unspecced.applyLabels',
6548
6590
  AppBskyUnspeccedGetPopular: 'app.bsky.unspecced.getPopular',
6549
6591
  AppBskyUnspeccedGetPopularFeedGenerators:
6550
6592
  'app.bsky.unspecced.getPopularFeedGenerators',
@@ -0,0 +1,33 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export interface InputSchema {
14
+ labels: ComAtprotoLabelDefs.Label[]
15
+ [k: string]: unknown
16
+ }
17
+
18
+ export interface CallOptions {
19
+ headers?: Headers
20
+ qp?: QueryParams
21
+ encoding: 'application/json'
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ }
28
+
29
+ export function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }
@@ -189,6 +189,7 @@ export interface RepoView {
189
189
  moderation: Moderation
190
190
  invitedBy?: ComAtprotoServerDefs.InviteCode
191
191
  invitesDisabled?: boolean
192
+ inviteNote?: string
192
193
  [k: string]: unknown
193
194
  }
194
195
 
@@ -215,6 +216,7 @@ export interface RepoViewDetail {
215
216
  invitedBy?: ComAtprotoServerDefs.InviteCode
216
217
  invites?: ComAtprotoServerDefs.InviteCode[]
217
218
  invitesDisabled?: boolean
219
+ inviteNote?: string
218
220
  [k: string]: unknown
219
221
  }
220
222
 
@@ -11,6 +11,8 @@ export interface QueryParams {}
11
11
 
12
12
  export interface InputSchema {
13
13
  account: string
14
+ /** Additionally add a note describing why the invites were disabled */
15
+ note?: string
14
16
  [k: string]: unknown
15
17
  }
16
18
 
@@ -11,6 +11,8 @@ export interface QueryParams {}
11
11
 
12
12
  export interface InputSchema {
13
13
  account: string
14
+ /** Additionally add a note describing why the invites were enabled */
15
+ note?: string
14
16
  [k: string]: unknown
15
17
  }
16
18
 
@@ -21,7 +21,7 @@ export const REASONSPAM = 'com.atproto.moderation.defs#reasonSpam'
21
21
  export const REASONVIOLATION = 'com.atproto.moderation.defs#reasonViolation'
22
22
  /** Misleading identity, affiliation, or content */
23
23
  export const REASONMISLEADING = 'com.atproto.moderation.defs#reasonMisleading'
24
- /** Unwanted or mis-labeled sexual content */
24
+ /** Unwanted or mislabeled sexual content */
25
25
  export const REASONSEXUAL = 'com.atproto.moderation.defs#reasonSexual'
26
26
  /** Rude, harassing, explicit, or otherwise unwelcoming behavior */
27
27
  export const REASONRUDE = 'com.atproto.moderation.defs#reasonRude'
package/src/index.ts CHANGED
@@ -13,5 +13,9 @@ export * from './agent'
13
13
  export * from './rich-text/rich-text'
14
14
  export * from './rich-text/sanitization'
15
15
  export * from './rich-text/unicode'
16
+ export * from './moderation'
17
+ export * from './moderation/types'
18
+ export { LABELS } from './moderation/const/labels'
19
+ export { LABEL_GROUPS } from './moderation/const/label-groups'
16
20
  export { BskyAgent } from './bsky-agent'
17
21
  export { AtpAgent as default } from './agent'
@@ -0,0 +1,181 @@
1
+ import { AppBskyGraphDefs } from '../client/index'
2
+ import {
3
+ Label,
4
+ LabelPreference,
5
+ ModerationCause,
6
+ ModerationOpts,
7
+ ModerationDecision,
8
+ } from './types'
9
+ import { LABELS } from './const/labels'
10
+
11
+ export class ModerationCauseAccumulator {
12
+ did = ''
13
+ causes: ModerationCause[] = []
14
+
15
+ constructor() {}
16
+
17
+ setDid(did: string) {
18
+ this.did = did
19
+ }
20
+
21
+ addBlocking(blocking: string | undefined) {
22
+ if (blocking) {
23
+ this.causes.push({
24
+ type: 'blocking',
25
+ source: { type: 'user' },
26
+ priority: 3,
27
+ })
28
+ }
29
+ }
30
+
31
+ addBlockedBy(blockedBy: boolean | undefined) {
32
+ if (blockedBy) {
33
+ this.causes.push({
34
+ type: 'blocked-by',
35
+ source: { type: 'user' },
36
+ priority: 4,
37
+ })
38
+ }
39
+ }
40
+
41
+ addLabel(label: Label, opts: ModerationOpts) {
42
+ // look up the label definition
43
+ const labelDef = LABELS[label.val]
44
+ if (!labelDef) {
45
+ // ignore labels we don't understand
46
+ return
47
+ }
48
+
49
+ // look up the label preference
50
+ // TODO use the find() when 3P labelers support lands
51
+ // const labelerSettings = opts.labelerSettings.find(
52
+ // (s) => s.labeler.did === label.src,
53
+ // )
54
+ const labelerSettings = opts.labelerSettings[0]
55
+ if (!labelerSettings) {
56
+ // ignore labels from labelers we don't use
57
+ return
58
+ }
59
+
60
+ // establish the label preference for interpretation
61
+ let labelPref: LabelPreference = 'ignore'
62
+ if (!labelDef.configurable) {
63
+ labelPref = labelDef.preferences[0]
64
+ } else if (labelDef.flags.includes('adult') && !opts.adultContentEnabled) {
65
+ labelPref = 'hide'
66
+ } else if (labelerSettings.settings[label.val]) {
67
+ labelPref = labelerSettings.settings[label.val]
68
+ }
69
+
70
+ // ignore labels the user has asked to ignore
71
+ if (labelPref === 'ignore') {
72
+ return
73
+ }
74
+
75
+ // establish the priority of the label
76
+ let priority: 1 | 2 | 5 | 7 | 8
77
+ if (labelDef.flags.includes('no-override')) {
78
+ priority = 1
79
+ } else if (labelPref === 'hide') {
80
+ priority = 2
81
+ } else if (labelDef.onwarn === 'blur') {
82
+ priority = 5
83
+ } else if (labelDef.onwarn === 'blur-media') {
84
+ priority = 7
85
+ } else {
86
+ priority = 8
87
+ }
88
+
89
+ this.causes.push({
90
+ type: 'label',
91
+ label,
92
+ labelDef,
93
+ labeler: labelerSettings.labeler,
94
+ setting: labelPref,
95
+ priority,
96
+ })
97
+ }
98
+
99
+ addMuted(muted: boolean | undefined) {
100
+ if (muted) {
101
+ this.causes.push({
102
+ type: 'muted',
103
+ source: { type: 'user' },
104
+ priority: 6,
105
+ })
106
+ }
107
+ }
108
+
109
+ addMutedByList(mutedByList: AppBskyGraphDefs.ListViewBasic | undefined) {
110
+ if (mutedByList) {
111
+ this.causes.push({
112
+ type: 'muted',
113
+ source: { type: 'list', list: mutedByList },
114
+ priority: 6,
115
+ })
116
+ }
117
+ }
118
+
119
+ finalizeDecision(opts: ModerationOpts): ModerationDecision {
120
+ const mod = new ModerationDecision()
121
+ mod.did = this.did
122
+ if (!this.causes.length) {
123
+ return mod
124
+ }
125
+
126
+ // sort the causes by priority and then choose the top one
127
+ this.causes.sort((a, b) => a.priority - b.priority)
128
+ mod.cause = this.causes[0]
129
+ mod.additionalCauses = this.causes.slice(1)
130
+
131
+ // blocked user
132
+ if (mod.cause.type === 'blocking' || mod.cause.type === 'blocked-by') {
133
+ // filter and blur, dont allow override
134
+ mod.filter = true
135
+ mod.blur = true
136
+ mod.noOverride = true
137
+ }
138
+ // muted user
139
+ else if (mod.cause.type === 'muted') {
140
+ // filter and blur
141
+ mod.filter = true
142
+ mod.blur = true
143
+ }
144
+ // labeled subject
145
+ else if (mod.cause.type === 'label') {
146
+ // 'hide' setting
147
+ if (mod.cause.setting === 'hide') {
148
+ // filter
149
+ mod.filter = true
150
+ }
151
+
152
+ // 'hide' and 'warn' setting, apply onwarn
153
+ switch (mod.cause.labelDef.onwarn) {
154
+ case 'alert':
155
+ mod.alert = true
156
+ break
157
+ case 'blur':
158
+ mod.blur = true
159
+ break
160
+ case 'blur-media':
161
+ mod.blurMedia = true
162
+ break
163
+ case null:
164
+ // do nothing
165
+ break
166
+ }
167
+
168
+ // apply noOverride as needed
169
+ if (mod.cause.labelDef.flags.includes('no-override')) {
170
+ mod.noOverride = true
171
+ } else if (
172
+ mod.cause.labelDef.flags.includes('adult') &&
173
+ !opts.adultContentEnabled
174
+ ) {
175
+ mod.noOverride = true
176
+ }
177
+ }
178
+
179
+ return mod
180
+ }
181
+ }
@@ -0,0 +1,143 @@
1
+ /** this doc is generated by ./scripts/code/labels.mjs **/
2
+ import { LabelGroupDefinitionMap } from '../types'
3
+ import { LABELS } from './labels'
4
+
5
+ export const LABEL_GROUPS: LabelGroupDefinitionMap = {
6
+ system: {
7
+ id: 'system',
8
+ configurable: false,
9
+ labels: [LABELS['!hide'], LABELS['!no-promote'], LABELS['!warn']],
10
+ strings: {
11
+ settings: {
12
+ en: {
13
+ name: 'System',
14
+ description: 'Moderator overrides for special cases.',
15
+ },
16
+ },
17
+ },
18
+ },
19
+ legal: {
20
+ id: 'legal',
21
+ configurable: false,
22
+ labels: [LABELS['dmca-violation'], LABELS['doxxing']],
23
+ strings: {
24
+ settings: {
25
+ en: {
26
+ name: 'Legal',
27
+ description: 'Content removed for legal reasons.',
28
+ },
29
+ },
30
+ },
31
+ },
32
+ sexual: {
33
+ id: 'sexual',
34
+ configurable: true,
35
+ labels: [LABELS['porn'], LABELS['sexual'], LABELS['nudity']],
36
+ strings: {
37
+ settings: {
38
+ en: {
39
+ name: 'Adult Content',
40
+ description: 'Content which is sexual in nature.',
41
+ },
42
+ },
43
+ },
44
+ },
45
+ violence: {
46
+ id: 'violence',
47
+ configurable: true,
48
+ labels: [
49
+ LABELS['nsfl'],
50
+ LABELS['corpse'],
51
+ LABELS['gore'],
52
+ LABELS['torture'],
53
+ LABELS['self-harm'],
54
+ ],
55
+ strings: {
56
+ settings: {
57
+ en: {
58
+ name: 'Violence',
59
+ description: 'Content which is violent or deeply disturbing.',
60
+ },
61
+ },
62
+ },
63
+ },
64
+ intolerance: {
65
+ id: 'intolerance',
66
+ configurable: true,
67
+ labels: [
68
+ LABELS['intolerant-race'],
69
+ LABELS['intolerant-gender'],
70
+ LABELS['intolerant-sexual-orientation'],
71
+ LABELS['intolerant-religion'],
72
+ LABELS['intolerant'],
73
+ LABELS['icon-intolerant'],
74
+ ],
75
+ strings: {
76
+ settings: {
77
+ en: {
78
+ name: 'Intolerance',
79
+ description:
80
+ 'Content or behavior which is hateful or intolerant toward a group of people.',
81
+ },
82
+ },
83
+ },
84
+ },
85
+ rude: {
86
+ id: 'rude',
87
+ configurable: true,
88
+ labels: [LABELS['threat']],
89
+ strings: {
90
+ settings: {
91
+ en: {
92
+ name: 'Rude',
93
+ description: 'Behavior which is rude toward other users.',
94
+ },
95
+ },
96
+ },
97
+ },
98
+ curation: {
99
+ id: 'curation',
100
+ configurable: true,
101
+ labels: [LABELS['spoiler']],
102
+ strings: {
103
+ settings: {
104
+ en: {
105
+ name: 'Curational',
106
+ description:
107
+ 'Subjective moderation geared towards curating a more positive environment.',
108
+ },
109
+ },
110
+ },
111
+ },
112
+ spam: {
113
+ id: 'spam',
114
+ configurable: true,
115
+ labels: [LABELS['spam']],
116
+ strings: {
117
+ settings: {
118
+ en: {
119
+ name: 'Spam',
120
+ description: "Content which doesn't add to the conversation.",
121
+ },
122
+ },
123
+ },
124
+ },
125
+ misinfo: {
126
+ id: 'misinfo',
127
+ configurable: true,
128
+ labels: [
129
+ LABELS['account-security'],
130
+ LABELS['net-abuse'],
131
+ LABELS['impersonation'],
132
+ LABELS['scam'],
133
+ ],
134
+ strings: {
135
+ settings: {
136
+ en: {
137
+ name: 'Misinformation',
138
+ description: 'Content which misleads or defrauds users.',
139
+ },
140
+ },
141
+ },
142
+ },
143
+ }