@atproto/api 0.1.3 → 0.2.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 (205) hide show
  1. package/README.md +179 -25
  2. package/build.js +2 -1
  3. package/dist/agent.d.ts +11 -6
  4. package/dist/bsky-agent.d.ts +43 -0
  5. package/dist/client/index.d.ts +117 -215
  6. package/dist/client/lexicons.d.ts +1440 -1401
  7. package/dist/client/types/app/bsky/actor/defs.d.ts +47 -0
  8. package/dist/client/types/app/bsky/actor/getProfile.d.ts +2 -2
  9. package/dist/client/types/app/bsky/actor/getProfiles.d.ts +2 -2
  10. package/dist/client/types/app/bsky/actor/getSuggestions.d.ts +2 -2
  11. package/dist/client/types/app/bsky/actor/profile.d.ts +4 -60
  12. package/dist/client/types/app/bsky/actor/searchActors.d.ts +22 -0
  13. package/dist/client/types/app/bsky/actor/searchActorsTypeahead.d.ts +20 -0
  14. package/dist/client/types/app/bsky/actor/updateProfile.d.ts +3 -10
  15. package/dist/client/types/app/bsky/embed/external.d.ts +9 -13
  16. package/dist/client/types/app/bsky/embed/images.d.ts +9 -13
  17. package/dist/client/types/app/bsky/embed/record.d.ts +21 -13
  18. package/dist/client/types/app/bsky/embed/recordWithMedia.d.ts +24 -0
  19. package/dist/client/types/app/bsky/feed/defs.d.ts +77 -0
  20. package/dist/client/types/app/bsky/feed/getAuthorFeed.d.ts +4 -4
  21. package/dist/client/types/app/bsky/feed/getLikes.d.ts +34 -0
  22. package/dist/client/types/app/bsky/feed/getPostThread.d.ts +2 -24
  23. package/dist/client/types/app/bsky/feed/getRepostedBy.d.ts +3 -3
  24. package/dist/client/types/app/bsky/feed/getTimeline.d.ts +3 -3
  25. package/dist/client/types/app/bsky/feed/like.d.ts +9 -0
  26. package/dist/client/types/app/bsky/feed/post.d.ts +4 -29
  27. package/dist/client/types/app/bsky/graph/follow.d.ts +1 -2
  28. package/dist/client/types/app/bsky/graph/getFollowers.d.ts +5 -5
  29. package/dist/client/types/app/bsky/graph/getFollows.d.ts +5 -5
  30. package/dist/client/types/app/bsky/graph/getMutes.d.ts +3 -3
  31. package/dist/client/types/app/bsky/graph/muteActor.d.ts +17 -0
  32. package/dist/client/types/app/bsky/graph/unmuteActor.d.ts +17 -0
  33. package/dist/client/types/app/bsky/notification/getUnreadCount.d.ts +17 -0
  34. package/dist/client/types/app/bsky/notification/listNotifications.d.ts +35 -0
  35. package/dist/client/types/app/bsky/richtext/facet.d.ts +30 -0
  36. package/dist/client/types/app/bsky/unspecced/getPopular.d.ts +21 -0
  37. package/dist/client/types/com/atproto/admin/defs.d.ts +181 -0
  38. package/dist/client/types/com/atproto/admin/getModerationAction.d.ts +2 -2
  39. package/dist/client/types/com/atproto/admin/getModerationActions.d.ts +3 -3
  40. package/dist/client/types/com/atproto/admin/getModerationReport.d.ts +2 -2
  41. package/dist/client/types/com/atproto/admin/getModerationReports.d.ts +3 -3
  42. package/dist/client/types/com/atproto/admin/getRecord.d.ts +2 -2
  43. package/dist/client/types/com/atproto/admin/getRepo.d.ts +2 -2
  44. package/dist/client/types/com/atproto/admin/resolveModerationReports.d.ts +2 -2
  45. package/dist/client/types/com/atproto/admin/reverseModerationAction.d.ts +2 -2
  46. package/dist/client/types/com/atproto/admin/searchRepos.d.ts +3 -3
  47. package/dist/client/types/com/atproto/admin/takeModerationAction.d.ts +5 -6
  48. package/dist/client/types/com/atproto/identity/resolveHandle.d.ts +18 -0
  49. package/dist/client/types/com/atproto/identity/updateHandle.d.ts +17 -0
  50. package/dist/client/types/com/atproto/moderation/createReport.d.ts +38 -0
  51. package/dist/client/types/com/atproto/moderation/defs.d.ts +3 -0
  52. package/dist/client/types/com/atproto/repo/applyWrites.d.ts +47 -0
  53. package/dist/client/types/com/atproto/repo/createRecord.d.ts +7 -2
  54. package/dist/client/types/com/atproto/repo/deleteRecord.d.ts +7 -2
  55. package/dist/client/types/com/atproto/repo/describeRepo.d.ts +22 -0
  56. package/dist/client/types/com/atproto/repo/getRecord.d.ts +1 -1
  57. package/dist/client/types/com/atproto/repo/listRecords.d.ts +3 -3
  58. package/dist/client/types/com/atproto/repo/putRecord.d.ts +7 -2
  59. package/dist/client/types/com/atproto/repo/uploadBlob.d.ts +20 -0
  60. package/dist/client/types/com/atproto/server/createAccount.d.ts +44 -0
  61. package/dist/client/types/com/atproto/server/createInviteCode.d.ts +22 -0
  62. package/dist/client/types/com/atproto/server/createSession.d.ts +29 -0
  63. package/dist/client/types/com/atproto/server/deleteAccount.d.ts +25 -0
  64. package/dist/client/types/com/atproto/server/deleteSession.d.ts +13 -0
  65. package/dist/client/types/com/atproto/server/describeServer.d.ts +27 -0
  66. package/dist/client/types/com/atproto/server/getSession.d.ts +18 -0
  67. package/dist/client/types/com/atproto/server/refreshSession.d.ts +24 -0
  68. package/dist/client/types/com/atproto/server/requestAccountDelete.d.ts +13 -0
  69. package/dist/client/types/com/atproto/server/requestPasswordReset.d.ts +17 -0
  70. package/dist/client/types/com/atproto/server/resetPassword.d.ts +24 -0
  71. package/dist/client/types/com/atproto/sync/getBlob.d.ts +15 -0
  72. package/dist/client/types/com/atproto/sync/listBlobs.d.ts +20 -0
  73. package/dist/client/types/com/atproto/sync/notifyOfUpdate.d.ts +1 -0
  74. package/dist/client/types/com/atproto/sync/requestCrawl.d.ts +1 -1
  75. package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +9 -1
  76. package/dist/client/types/com/atproto/sync/subscribeRepos.d.ts +58 -0
  77. package/dist/helpers/bsky.d.ts +20 -0
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.js +8046 -3649
  80. package/dist/index.js.map +4 -4
  81. package/dist/mixins/bsky.d.ts +23 -0
  82. package/dist/rich-text/detection.d.ts +4 -0
  83. package/dist/rich-text/rich-text.d.ts +39 -0
  84. package/dist/rich-text/sanitization.d.ts +4 -0
  85. package/dist/rich-text/sanitize.d.ts +4 -0
  86. package/dist/rich-text/unicode.d.ts +11 -0
  87. package/dist/types.d.ts +2 -2
  88. package/docs/rn-fetch-handler.ts +88 -0
  89. package/package.json +4 -1
  90. package/src/agent.ts +51 -15
  91. package/src/bsky-agent.ts +228 -0
  92. package/src/client/index.ts +330 -581
  93. package/src/client/lexicons.ts +1824 -1777
  94. package/src/client/types/app/bsky/actor/defs.ts +97 -0
  95. package/src/client/types/app/bsky/actor/getProfile.ts +4 -3
  96. package/src/client/types/app/bsky/actor/getProfiles.ts +4 -3
  97. package/src/client/types/app/bsky/actor/getSuggestions.ts +4 -3
  98. package/src/client/types/app/bsky/actor/profile.ts +5 -95
  99. package/src/client/types/app/bsky/actor/{searchTypeahead.ts → searchActors.ts} +6 -3
  100. package/src/client/types/app/bsky/actor/{search.ts → searchActorsTypeahead.ts} +4 -5
  101. package/src/client/types/app/bsky/embed/external.ts +14 -13
  102. package/src/client/types/app/bsky/embed/images.ts +14 -15
  103. package/src/client/types/app/bsky/embed/record.ts +32 -25
  104. package/src/client/types/app/bsky/embed/recordWithMedia.ts +53 -0
  105. package/src/client/types/app/bsky/feed/defs.ts +156 -0
  106. package/src/client/types/app/bsky/feed/getAuthorFeed.ts +6 -5
  107. package/src/client/types/app/bsky/feed/{getVotes.ts → getLikes.ts} +11 -12
  108. package/src/client/types/app/bsky/feed/getPostThread.ts +5 -48
  109. package/src/client/types/app/bsky/feed/getRepostedBy.ts +5 -4
  110. package/src/client/types/app/bsky/feed/getTimeline.ts +5 -4
  111. package/src/client/types/app/bsky/feed/{vote.ts → like.ts} +4 -4
  112. package/src/client/types/app/bsky/feed/post.ts +10 -52
  113. package/src/client/types/app/bsky/feed/repost.ts +2 -1
  114. package/src/client/types/app/bsky/graph/follow.ts +3 -3
  115. package/src/client/types/app/bsky/graph/getFollowers.ts +7 -6
  116. package/src/client/types/app/bsky/graph/getFollows.ts +7 -6
  117. package/src/client/types/app/bsky/graph/getMutes.ts +5 -4
  118. package/src/client/types/app/bsky/graph/{mute.ts → muteActor.ts} +3 -2
  119. package/src/client/types/app/bsky/graph/{unmute.ts → unmuteActor.ts} +3 -2
  120. package/src/client/types/app/bsky/notification/{getCount.ts → getUnreadCount.ts} +2 -1
  121. package/src/client/types/app/bsky/notification/{list.ts → listNotifications.ts} +13 -9
  122. package/src/client/types/app/bsky/notification/updateSeen.ts +2 -1
  123. package/src/client/types/app/bsky/richtext/facet.ts +81 -0
  124. package/src/client/types/app/bsky/unspecced/getPopular.ts +38 -0
  125. package/src/client/types/com/atproto/admin/defs.ts +366 -0
  126. package/src/client/types/com/atproto/admin/getModerationAction.ts +4 -3
  127. package/src/client/types/com/atproto/admin/getModerationActions.ts +5 -4
  128. package/src/client/types/com/atproto/admin/getModerationReport.ts +4 -3
  129. package/src/client/types/com/atproto/admin/getModerationReports.ts +5 -4
  130. package/src/client/types/com/atproto/admin/getRecord.ts +4 -3
  131. package/src/client/types/com/atproto/admin/getRepo.ts +4 -3
  132. package/src/client/types/com/atproto/admin/resolveModerationReports.ts +4 -3
  133. package/src/client/types/com/atproto/admin/reverseModerationAction.ts +4 -3
  134. package/src/client/types/com/atproto/admin/searchRepos.ts +5 -4
  135. package/src/client/types/com/atproto/admin/takeModerationAction.ts +10 -10
  136. package/src/client/types/com/atproto/{handle/resolve.ts → identity/resolveHandle.ts} +2 -1
  137. package/src/client/types/com/atproto/{handle/update.ts → identity/updateHandle.ts} +2 -1
  138. package/src/client/types/com/atproto/{report/create.ts → moderation/createReport.ts} +10 -10
  139. package/src/client/types/com/atproto/moderation/defs.ts +17 -0
  140. package/src/client/types/com/atproto/repo/{batchWrite.ts → applyWrites.ts} +21 -12
  141. package/src/client/types/com/atproto/repo/createRecord.ts +15 -3
  142. package/src/client/types/com/atproto/repo/deleteRecord.ts +15 -3
  143. package/src/client/types/com/atproto/repo/{describe.ts → describeRepo.ts} +3 -2
  144. package/src/client/types/com/atproto/repo/getRecord.ts +4 -3
  145. package/src/client/types/com/atproto/repo/listRecords.ts +7 -6
  146. package/src/client/types/com/atproto/repo/putRecord.ts +18 -6
  147. package/src/client/types/com/atproto/repo/strongRef.ts +2 -1
  148. package/src/client/types/com/atproto/{blob/upload.ts → repo/uploadBlob.ts} +3 -2
  149. package/src/client/types/com/atproto/{account/create.ts → server/createAccount.ts} +9 -1
  150. package/src/client/types/com/atproto/{account → server}/createInviteCode.ts +2 -1
  151. package/src/client/types/com/atproto/{session/create.ts → server/createSession.ts} +2 -1
  152. package/src/client/types/com/atproto/{account/delete.ts → server/deleteAccount.ts} +2 -1
  153. package/src/client/types/com/atproto/{account/requestDelete.ts → server/deleteSession.ts} +2 -1
  154. package/src/client/types/com/atproto/server/{getAccountsConfig.ts → describeServer.ts} +4 -3
  155. package/src/client/types/com/atproto/{session/get.ts → server/getSession.ts} +2 -1
  156. package/src/client/types/com/atproto/{session/refresh.ts → server/refreshSession.ts} +2 -1
  157. package/src/client/types/com/atproto/{session/delete.ts → server/requestAccountDelete.ts} +2 -1
  158. package/src/client/types/com/atproto/{account → server}/requestPasswordReset.ts +2 -1
  159. package/src/client/types/com/atproto/{account → server}/resetPassword.ts +2 -1
  160. package/src/client/types/com/atproto/sync/getBlob.ts +33 -0
  161. package/src/client/types/com/atproto/sync/getBlocks.ts +2 -1
  162. package/src/client/types/com/atproto/sync/getCheckout.ts +2 -1
  163. package/src/client/types/com/atproto/sync/getCommitPath.ts +2 -1
  164. package/src/client/types/com/atproto/sync/getHead.ts +2 -1
  165. package/src/client/types/com/atproto/sync/getRecord.ts +2 -1
  166. package/src/client/types/com/atproto/sync/getRepo.ts +2 -1
  167. package/src/client/types/com/atproto/sync/listBlobs.ts +40 -0
  168. package/src/client/types/com/atproto/sync/notifyOfUpdate.ts +6 -2
  169. package/src/client/types/com/atproto/sync/requestCrawl.ts +3 -2
  170. package/src/client/types/com/atproto/sync/subscribeRepos.ts +131 -0
  171. package/src/index.ts +12 -0
  172. package/src/rich-text/detection.ts +83 -0
  173. package/src/rich-text/rich-text.ts +401 -0
  174. package/src/rich-text/sanitization.ts +40 -0
  175. package/src/rich-text/unicode.ts +47 -0
  176. package/src/types.ts +2 -2
  177. package/tests/agent.test.ts +10 -6
  178. package/tests/bsky-agent.test.ts +140 -0
  179. package/tests/errors.test.ts +4 -4
  180. package/tests/rich-text-detection.test.ts +229 -0
  181. package/tests/rich-text-sanitization.test.ts +211 -0
  182. package/tests/rich-text.test.ts +661 -0
  183. package/tsconfig.build.tsbuildinfo +1 -1
  184. package/src/client/types/app/bsky/actor/ref.ts +0 -64
  185. package/src/client/types/app/bsky/actor/updateProfile.ts +0 -71
  186. package/src/client/types/app/bsky/feed/feedViewPost.ts +0 -64
  187. package/src/client/types/app/bsky/feed/setVote.ts +0 -40
  188. package/src/client/types/app/bsky/graph/assertCreator.ts +0 -9
  189. package/src/client/types/app/bsky/graph/assertMember.ts +0 -9
  190. package/src/client/types/app/bsky/graph/assertion.ts +0 -27
  191. package/src/client/types/app/bsky/graph/confirmation.ts +0 -28
  192. package/src/client/types/app/bsky/system/actorUser.ts +0 -9
  193. package/src/client/types/app/bsky/system/declRef.ts +0 -26
  194. package/src/client/types/app/bsky/system/declaration.ts +0 -24
  195. package/src/client/types/com/atproto/account/get.ts +0 -26
  196. package/src/client/types/com/atproto/admin/blob.ts +0 -84
  197. package/src/client/types/com/atproto/admin/moderationAction.ts +0 -118
  198. package/src/client/types/com/atproto/admin/moderationReport.ts +0 -64
  199. package/src/client/types/com/atproto/admin/record.ts +0 -92
  200. package/src/client/types/com/atproto/admin/repo.ts +0 -103
  201. package/src/client/types/com/atproto/repo/recordRef.ts +0 -25
  202. package/src/client/types/com/atproto/repo/repoRef.ts +0 -24
  203. package/src/client/types/com/atproto/report/reasonType.ts +0 -16
  204. package/src/client/types/com/atproto/report/subject.ts +0 -66
  205. package/src/client/types/com/atproto/sync/subscribeAllRepos.ts +0 -7
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -43,10 +44,10 @@ export function isLinks(v: unknown): v is Links {
43
44
  return (
44
45
  isObj(v) &&
45
46
  hasProp(v, '$type') &&
46
- v.$type === 'com.atproto.server.getAccountsConfig#links'
47
+ v.$type === 'com.atproto.server.describeServer#links'
47
48
  )
48
49
  }
49
50
 
50
51
  export function validateLinks(v: unknown): ValidationResult {
51
- return lexicons.validate('com.atproto.server.getAccountsConfig#links', v)
52
+ return lexicons.validate('com.atproto.server.describeServer#links', v)
52
53
  }
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {}
10
11
 
@@ -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
+
10
+ export interface QueryParams {
11
+ /** The DID of the repo. */
12
+ did: string
13
+ /** The CID of the blob to fetch */
14
+ cid: string
15
+ }
16
+
17
+ export type InputSchema = undefined
18
+
19
+ export interface CallOptions {
20
+ headers?: Headers
21
+ }
22
+
23
+ export interface Response {
24
+ success: boolean
25
+ headers: Headers
26
+ data: Uint8Array
27
+ }
28
+
29
+ export function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -2,9 +2,10 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** The DID of the repo. */
@@ -0,0 +1,40 @@
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
+
10
+ export interface QueryParams {
11
+ /** The DID of the repo. */
12
+ did: string
13
+ /** The most recent commit */
14
+ latest?: string
15
+ /** The earliest commit to start from */
16
+ earliest?: string
17
+ }
18
+
19
+ export type InputSchema = undefined
20
+
21
+ export interface OutputSchema {
22
+ cids: string[]
23
+ [k: string]: unknown
24
+ }
25
+
26
+ export interface CallOptions {
27
+ headers?: Headers
28
+ }
29
+
30
+ export interface Response {
31
+ success: boolean
32
+ headers: Headers
33
+ data: OutputSchema
34
+ }
35
+
36
+ export function toKnownErr(e: any) {
37
+ if (e instanceof XRPCError) {
38
+ }
39
+ return e
40
+ }
@@ -2,11 +2,15 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
- export interface QueryParams {}
10
+ export interface QueryParams {
11
+ /** Hostname of the service that is notifying of update. */
12
+ hostname: string
13
+ }
10
14
 
11
15
  export type InputSchema = undefined
12
16
 
@@ -2,13 +2,14 @@
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
4
  import { Headers, XRPCError } from '@atproto/xrpc'
5
- import { ValidationResult } from '@atproto/lexicon'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
8
9
 
9
10
  export interface QueryParams {
10
11
  /** Hostname of the service that is requesting to be crawled. */
11
- host?: string
12
+ hostname: string
12
13
  }
13
14
 
14
15
  export type InputSchema = undefined
@@ -0,0 +1,131 @@
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
+
10
+ export interface Commit {
11
+ seq: number
12
+ rebase: boolean
13
+ tooBig: boolean
14
+ repo: string
15
+ commit: CID
16
+ prev: CID | null
17
+ /** CAR file containing relevant blocks */
18
+ blocks: Uint8Array
19
+ ops: RepoOp[]
20
+ blobs: CID[]
21
+ time: string
22
+ [k: string]: unknown
23
+ }
24
+
25
+ export function isCommit(v: unknown): v is Commit {
26
+ return (
27
+ isObj(v) &&
28
+ hasProp(v, '$type') &&
29
+ v.$type === 'com.atproto.sync.subscribeRepos#commit'
30
+ )
31
+ }
32
+
33
+ export function validateCommit(v: unknown): ValidationResult {
34
+ return lexicons.validate('com.atproto.sync.subscribeRepos#commit', v)
35
+ }
36
+
37
+ export interface Handle {
38
+ seq: number
39
+ did: string
40
+ handle: string
41
+ time: string
42
+ [k: string]: unknown
43
+ }
44
+
45
+ export function isHandle(v: unknown): v is Handle {
46
+ return (
47
+ isObj(v) &&
48
+ hasProp(v, '$type') &&
49
+ v.$type === 'com.atproto.sync.subscribeRepos#handle'
50
+ )
51
+ }
52
+
53
+ export function validateHandle(v: unknown): ValidationResult {
54
+ return lexicons.validate('com.atproto.sync.subscribeRepos#handle', v)
55
+ }
56
+
57
+ export interface Migrate {
58
+ seq: number
59
+ did: string
60
+ migrateTo: string | null
61
+ time: string
62
+ [k: string]: unknown
63
+ }
64
+
65
+ export function isMigrate(v: unknown): v is Migrate {
66
+ return (
67
+ isObj(v) &&
68
+ hasProp(v, '$type') &&
69
+ v.$type === 'com.atproto.sync.subscribeRepos#migrate'
70
+ )
71
+ }
72
+
73
+ export function validateMigrate(v: unknown): ValidationResult {
74
+ return lexicons.validate('com.atproto.sync.subscribeRepos#migrate', v)
75
+ }
76
+
77
+ export interface Tombstone {
78
+ seq: number
79
+ did: string
80
+ time: string
81
+ [k: string]: unknown
82
+ }
83
+
84
+ export function isTombstone(v: unknown): v is Tombstone {
85
+ return (
86
+ isObj(v) &&
87
+ hasProp(v, '$type') &&
88
+ v.$type === 'com.atproto.sync.subscribeRepos#tombstone'
89
+ )
90
+ }
91
+
92
+ export function validateTombstone(v: unknown): ValidationResult {
93
+ return lexicons.validate('com.atproto.sync.subscribeRepos#tombstone', v)
94
+ }
95
+
96
+ export interface Info {
97
+ name: 'OutdatedCursor' | (string & {})
98
+ message?: string
99
+ [k: string]: unknown
100
+ }
101
+
102
+ export function isInfo(v: unknown): v is Info {
103
+ return (
104
+ isObj(v) &&
105
+ hasProp(v, '$type') &&
106
+ v.$type === 'com.atproto.sync.subscribeRepos#info'
107
+ )
108
+ }
109
+
110
+ export function validateInfo(v: unknown): ValidationResult {
111
+ return lexicons.validate('com.atproto.sync.subscribeRepos#info', v)
112
+ }
113
+
114
+ export interface RepoOp {
115
+ action: 'create' | 'update' | 'delete' | (string & {})
116
+ path: string
117
+ cid: CID | null
118
+ [k: string]: unknown
119
+ }
120
+
121
+ export function isRepoOp(v: unknown): v is RepoOp {
122
+ return (
123
+ isObj(v) &&
124
+ hasProp(v, '$type') &&
125
+ v.$type === 'com.atproto.sync.subscribeRepos#repoOp'
126
+ )
127
+ }
128
+
129
+ export function validateRepoOp(v: unknown): ValidationResult {
130
+ return lexicons.validate('com.atproto.sync.subscribeRepos#repoOp', v)
131
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,16 @@
1
+ export { AtUri } from '@atproto/uri'
2
+ export {
3
+ BlobRef,
4
+ lexToJson,
5
+ stringifyLex,
6
+ jsonToLex,
7
+ jsonStringToLex,
8
+ } from '@atproto/lexicon'
1
9
  export * from './types'
2
10
  export * from './client'
3
11
  export * from './agent'
12
+ export * from './rich-text/rich-text'
13
+ export * from './rich-text/sanitization'
14
+ export * from './rich-text/unicode'
15
+ export { BskyAgent } from './bsky-agent'
4
16
  export { AtpAgent as default } from './agent'
@@ -0,0 +1,83 @@
1
+ import TLDs from 'tlds'
2
+ import { AppBskyRichtextFacet } from '../client'
3
+ import { UnicodeString } from './unicode'
4
+
5
+ export type Facet = AppBskyRichtextFacet.Main
6
+
7
+ export function detectFacets(text: UnicodeString): Facet[] | undefined {
8
+ let match
9
+ const facets: Facet[] = []
10
+ {
11
+ // mentions
12
+ const re = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g
13
+ while ((match = re.exec(text.utf16))) {
14
+ if (!isValidDomain(match[3]) && !match[3].endsWith('.test')) {
15
+ continue // probably not a handle
16
+ }
17
+
18
+ const start = text.utf16.indexOf(match[3], match.index) - 1
19
+ facets.push({
20
+ $type: 'app.bsky.richtext.facet',
21
+ index: {
22
+ byteStart: text.utf16IndexToUtf8Index(start),
23
+ byteEnd: text.utf16IndexToUtf8Index(start + match[3].length + 1),
24
+ },
25
+ features: [
26
+ {
27
+ $type: 'app.bsky.richtext.facet#mention',
28
+ did: match[3], // must be resolved afterwards
29
+ },
30
+ ],
31
+ })
32
+ }
33
+ }
34
+ {
35
+ // links
36
+ const re =
37
+ /(^|\s|\()((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*))/gim
38
+ while ((match = re.exec(text.utf16))) {
39
+ let uri = match[2]
40
+ if (!uri.startsWith('http')) {
41
+ const domain = match.groups?.domain
42
+ if (!domain || !isValidDomain(domain)) {
43
+ continue
44
+ }
45
+ uri = `https://${uri}`
46
+ }
47
+ const start = text.utf16.indexOf(match[2], match.index)
48
+ const index = { start, end: start + match[2].length }
49
+ // strip ending puncuation
50
+ if (/[.,;!?]$/.test(uri)) {
51
+ uri = uri.slice(0, -1)
52
+ index.end--
53
+ }
54
+ if (/[)]$/.test(uri) && !uri.includes('(')) {
55
+ uri = uri.slice(0, -1)
56
+ index.end--
57
+ }
58
+ facets.push({
59
+ index: {
60
+ byteStart: text.utf16IndexToUtf8Index(index.start),
61
+ byteEnd: text.utf16IndexToUtf8Index(index.end),
62
+ },
63
+ features: [
64
+ {
65
+ $type: 'app.bsky.richtext.facet#link',
66
+ uri,
67
+ },
68
+ ],
69
+ })
70
+ }
71
+ }
72
+ return facets.length > 0 ? facets : undefined
73
+ }
74
+
75
+ function isValidDomain(str: string): boolean {
76
+ return !!TLDs.find((tld) => {
77
+ const i = str.lastIndexOf(tld)
78
+ if (i === -1) {
79
+ return false
80
+ }
81
+ return str.charAt(i - 1) === '.' && i === str.length - tld.length
82
+ })
83
+ }