@atproto/lex-space 0.0.0-stage → 0.0.1

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 (363) hide show
  1. package/LICENSE.txt +7 -0
  2. package/README.md +463 -2
  3. package/dist/actions.d.ts +17 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +20 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/atproto-did-resolver.d.ts +3 -0
  8. package/dist/atproto-did-resolver.d.ts.map +1 -0
  9. package/dist/atproto-did-resolver.js +2 -0
  10. package/dist/atproto-did-resolver.js.map +1 -0
  11. package/dist/client-attestation-provider.d.ts +57 -0
  12. package/dist/client-attestation-provider.d.ts.map +1 -0
  13. package/dist/client-attestation-provider.js +51 -0
  14. package/dist/client-attestation-provider.js.map +1 -0
  15. package/dist/delegation-token-provider.d.ts +25 -0
  16. package/dist/delegation-token-provider.d.ts.map +1 -0
  17. package/dist/delegation-token-provider.js +28 -0
  18. package/dist/delegation-token-provider.js.map +1 -0
  19. package/dist/errors.d.ts +27 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +27 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +15 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +15 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lexicons/com/atproto/managedspace/policy.d.ts +3 -0
  28. package/dist/lexicons/com/atproto/managedspace/policy.d.ts.map +1 -0
  29. package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts +78 -0
  30. package/dist/lexicons/com/atproto/managedspace/policy.defs.d.ts.map +1 -0
  31. package/dist/lexicons/com/atproto/managedspace/policy.defs.js +23 -0
  32. package/dist/lexicons/com/atproto/managedspace/policy.defs.js.map +1 -0
  33. package/dist/lexicons/com/atproto/managedspace/policy.js +6 -0
  34. package/dist/lexicons/com/atproto/managedspace/policy.js.map +1 -0
  35. package/dist/lexicons/com/atproto/managedspace.d.ts +2 -0
  36. package/dist/lexicons/com/atproto/managedspace.d.ts.map +1 -0
  37. package/dist/lexicons/com/atproto/managedspace.js +5 -0
  38. package/dist/lexicons/com/atproto/managedspace.js.map +1 -0
  39. package/dist/lexicons/com/atproto/memberspace/defs.d.ts +2 -0
  40. package/dist/lexicons/com/atproto/memberspace/defs.d.ts.map +1 -0
  41. package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts +14 -0
  42. package/dist/lexicons/com/atproto/memberspace/defs.defs.d.ts.map +1 -0
  43. package/dist/lexicons/com/atproto/memberspace/defs.defs.js +9 -0
  44. package/dist/lexicons/com/atproto/memberspace/defs.defs.js.map +1 -0
  45. package/dist/lexicons/com/atproto/memberspace/defs.js +5 -0
  46. package/dist/lexicons/com/atproto/memberspace/defs.js.map +1 -0
  47. package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts +3 -0
  48. package/dist/lexicons/com/atproto/memberspace/listMembers.d.ts.map +1 -0
  49. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts +35 -0
  50. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.d.ts.map +1 -0
  51. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js +15 -0
  52. package/dist/lexicons/com/atproto/memberspace/listMembers.defs.js.map +1 -0
  53. package/dist/lexicons/com/atproto/memberspace/listMembers.js +6 -0
  54. package/dist/lexicons/com/atproto/memberspace/listMembers.js.map +1 -0
  55. package/dist/lexicons/com/atproto/memberspace/policy.d.ts +3 -0
  56. package/dist/lexicons/com/atproto/memberspace/policy.d.ts.map +1 -0
  57. package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts +120 -0
  58. package/dist/lexicons/com/atproto/memberspace/policy.defs.d.ts.map +1 -0
  59. package/dist/lexicons/com/atproto/memberspace/policy.defs.js +23 -0
  60. package/dist/lexicons/com/atproto/memberspace/policy.defs.js.map +1 -0
  61. package/dist/lexicons/com/atproto/memberspace/policy.js +6 -0
  62. package/dist/lexicons/com/atproto/memberspace/policy.js.map +1 -0
  63. package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts +3 -0
  64. package/dist/lexicons/com/atproto/memberspace/putMembers.d.ts.map +1 -0
  65. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts +30 -0
  66. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.d.ts.map +1 -0
  67. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js +16 -0
  68. package/dist/lexicons/com/atproto/memberspace/putMembers.defs.js.map +1 -0
  69. package/dist/lexicons/com/atproto/memberspace/putMembers.js +6 -0
  70. package/dist/lexicons/com/atproto/memberspace/putMembers.js.map +1 -0
  71. package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts +3 -0
  72. package/dist/lexicons/com/atproto/memberspace/removeMembers.d.ts.map +1 -0
  73. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts +33 -0
  74. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.d.ts.map +1 -0
  75. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js +15 -0
  76. package/dist/lexicons/com/atproto/memberspace/removeMembers.defs.js.map +1 -0
  77. package/dist/lexicons/com/atproto/memberspace/removeMembers.js +6 -0
  78. package/dist/lexicons/com/atproto/memberspace/removeMembers.js.map +1 -0
  79. package/dist/lexicons/com/atproto/memberspace.d.ts +6 -0
  80. package/dist/lexicons/com/atproto/memberspace.d.ts.map +1 -0
  81. package/dist/lexicons/com/atproto/memberspace.js +9 -0
  82. package/dist/lexicons/com/atproto/memberspace.js.map +1 -0
  83. package/dist/lexicons/com/atproto/personalspace/policy.d.ts +3 -0
  84. package/dist/lexicons/com/atproto/personalspace/policy.d.ts.map +1 -0
  85. package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts +50 -0
  86. package/dist/lexicons/com/atproto/personalspace/policy.defs.d.ts.map +1 -0
  87. package/dist/lexicons/com/atproto/personalspace/policy.defs.js +23 -0
  88. package/dist/lexicons/com/atproto/personalspace/policy.defs.js.map +1 -0
  89. package/dist/lexicons/com/atproto/personalspace/policy.js +6 -0
  90. package/dist/lexicons/com/atproto/personalspace/policy.js.map +1 -0
  91. package/dist/lexicons/com/atproto/personalspace.d.ts +2 -0
  92. package/dist/lexicons/com/atproto/personalspace.d.ts.map +1 -0
  93. package/dist/lexicons/com/atproto/personalspace.js +5 -0
  94. package/dist/lexicons/com/atproto/personalspace.js.map +1 -0
  95. package/dist/lexicons/com/atproto/space/applyWrites.d.ts +3 -0
  96. package/dist/lexicons/com/atproto/space/applyWrites.d.ts.map +1 -0
  97. package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts +97 -0
  98. package/dist/lexicons/com/atproto/space/applyWrites.defs.d.ts.map +1 -0
  99. package/dist/lexicons/com/atproto/space/applyWrites.defs.js +30 -0
  100. package/dist/lexicons/com/atproto/space/applyWrites.defs.js.map +1 -0
  101. package/dist/lexicons/com/atproto/space/applyWrites.js +6 -0
  102. package/dist/lexicons/com/atproto/space/applyWrites.js.map +1 -0
  103. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts +3 -0
  104. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.d.ts.map +1 -0
  105. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts +59 -0
  106. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.d.ts.map +1 -0
  107. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js +17 -0
  108. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.defs.js.map +1 -0
  109. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js +6 -0
  110. package/dist/lexicons/com/atproto/space/authorizeSpaceSync.js.map +1 -0
  111. package/dist/lexicons/com/atproto/space/clearRecords.d.ts +3 -0
  112. package/dist/lexicons/com/atproto/space/clearRecords.d.ts.map +1 -0
  113. package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts +33 -0
  114. package/dist/lexicons/com/atproto/space/clearRecords.defs.d.ts.map +1 -0
  115. package/dist/lexicons/com/atproto/space/clearRecords.defs.js +15 -0
  116. package/dist/lexicons/com/atproto/space/clearRecords.defs.js.map +1 -0
  117. package/dist/lexicons/com/atproto/space/clearRecords.js +6 -0
  118. package/dist/lexicons/com/atproto/space/clearRecords.js.map +1 -0
  119. package/dist/lexicons/com/atproto/space/createRecord.d.ts +3 -0
  120. package/dist/lexicons/com/atproto/space/createRecord.d.ts.map +1 -0
  121. package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts +69 -0
  122. package/dist/lexicons/com/atproto/space/createRecord.defs.d.ts.map +1 -0
  123. package/dist/lexicons/com/atproto/space/createRecord.defs.js +15 -0
  124. package/dist/lexicons/com/atproto/space/createRecord.defs.js.map +1 -0
  125. package/dist/lexicons/com/atproto/space/createRecord.js +6 -0
  126. package/dist/lexicons/com/atproto/space/createRecord.js.map +1 -0
  127. package/dist/lexicons/com/atproto/space/createSpace.d.ts +3 -0
  128. package/dist/lexicons/com/atproto/space/createSpace.d.ts.map +1 -0
  129. package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts +46 -0
  130. package/dist/lexicons/com/atproto/space/createSpace.defs.d.ts.map +1 -0
  131. package/dist/lexicons/com/atproto/space/createSpace.defs.js +18 -0
  132. package/dist/lexicons/com/atproto/space/createSpace.defs.js.map +1 -0
  133. package/dist/lexicons/com/atproto/space/createSpace.js +6 -0
  134. package/dist/lexicons/com/atproto/space/createSpace.js.map +1 -0
  135. package/dist/lexicons/com/atproto/space/defs.d.ts +2 -0
  136. package/dist/lexicons/com/atproto/space/defs.d.ts.map +1 -0
  137. package/dist/lexicons/com/atproto/space/defs.defs.d.ts +60 -0
  138. package/dist/lexicons/com/atproto/space/defs.defs.d.ts.map +1 -0
  139. package/dist/lexicons/com/atproto/space/defs.defs.js +16 -0
  140. package/dist/lexicons/com/atproto/space/defs.defs.js.map +1 -0
  141. package/dist/lexicons/com/atproto/space/defs.js +5 -0
  142. package/dist/lexicons/com/atproto/space/defs.js.map +1 -0
  143. package/dist/lexicons/com/atproto/space/deleteRecord.d.ts +3 -0
  144. package/dist/lexicons/com/atproto/space/deleteRecord.d.ts.map +1 -0
  145. package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts +45 -0
  146. package/dist/lexicons/com/atproto/space/deleteRecord.defs.d.ts.map +1 -0
  147. package/dist/lexicons/com/atproto/space/deleteRecord.defs.js +15 -0
  148. package/dist/lexicons/com/atproto/space/deleteRecord.defs.js.map +1 -0
  149. package/dist/lexicons/com/atproto/space/deleteRecord.js +6 -0
  150. package/dist/lexicons/com/atproto/space/deleteRecord.js.map +1 -0
  151. package/dist/lexicons/com/atproto/space/deleteSpace.d.ts +3 -0
  152. package/dist/lexicons/com/atproto/space/deleteSpace.d.ts.map +1 -0
  153. package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts +27 -0
  154. package/dist/lexicons/com/atproto/space/deleteSpace.defs.d.ts.map +1 -0
  155. package/dist/lexicons/com/atproto/space/deleteSpace.defs.js +15 -0
  156. package/dist/lexicons/com/atproto/space/deleteSpace.defs.js.map +1 -0
  157. package/dist/lexicons/com/atproto/space/deleteSpace.js +6 -0
  158. package/dist/lexicons/com/atproto/space/deleteSpace.js.map +1 -0
  159. package/dist/lexicons/com/atproto/space/getBlob.d.ts +3 -0
  160. package/dist/lexicons/com/atproto/space/getBlob.d.ts.map +1 -0
  161. package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts +36 -0
  162. package/dist/lexicons/com/atproto/space/getBlob.defs.d.ts.map +1 -0
  163. package/dist/lexicons/com/atproto/space/getBlob.defs.js +14 -0
  164. package/dist/lexicons/com/atproto/space/getBlob.defs.js.map +1 -0
  165. package/dist/lexicons/com/atproto/space/getBlob.js +6 -0
  166. package/dist/lexicons/com/atproto/space/getBlob.js.map +1 -0
  167. package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts +3 -0
  168. package/dist/lexicons/com/atproto/space/getDelegationToken.d.ts.map +1 -0
  169. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts +28 -0
  170. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.d.ts.map +1 -0
  171. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js +14 -0
  172. package/dist/lexicons/com/atproto/space/getDelegationToken.defs.js.map +1 -0
  173. package/dist/lexicons/com/atproto/space/getDelegationToken.js +6 -0
  174. package/dist/lexicons/com/atproto/space/getDelegationToken.js.map +1 -0
  175. package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts +3 -0
  176. package/dist/lexicons/com/atproto/space/getLatestCommit.d.ts.map +1 -0
  177. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts +35 -0
  178. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.d.ts.map +1 -0
  179. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js +15 -0
  180. package/dist/lexicons/com/atproto/space/getLatestCommit.defs.js.map +1 -0
  181. package/dist/lexicons/com/atproto/space/getLatestCommit.js +6 -0
  182. package/dist/lexicons/com/atproto/space/getLatestCommit.js.map +1 -0
  183. package/dist/lexicons/com/atproto/space/getRecord.d.ts +3 -0
  184. package/dist/lexicons/com/atproto/space/getRecord.d.ts.map +1 -0
  185. package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts +58 -0
  186. package/dist/lexicons/com/atproto/space/getRecord.defs.d.ts.map +1 -0
  187. package/dist/lexicons/com/atproto/space/getRecord.defs.js +14 -0
  188. package/dist/lexicons/com/atproto/space/getRecord.defs.js.map +1 -0
  189. package/dist/lexicons/com/atproto/space/getRecord.js +6 -0
  190. package/dist/lexicons/com/atproto/space/getRecord.js.map +1 -0
  191. package/dist/lexicons/com/atproto/space/getRepo.d.ts +3 -0
  192. package/dist/lexicons/com/atproto/space/getRepo.d.ts.map +1 -0
  193. package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts +30 -0
  194. package/dist/lexicons/com/atproto/space/getRepo.defs.d.ts.map +1 -0
  195. package/dist/lexicons/com/atproto/space/getRepo.defs.js +14 -0
  196. package/dist/lexicons/com/atproto/space/getRepo.defs.js.map +1 -0
  197. package/dist/lexicons/com/atproto/space/getRepo.js +6 -0
  198. package/dist/lexicons/com/atproto/space/getRepo.js.map +1 -0
  199. package/dist/lexicons/com/atproto/space/getSpace.d.ts +3 -0
  200. package/dist/lexicons/com/atproto/space/getSpace.d.ts.map +1 -0
  201. package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts +37 -0
  202. package/dist/lexicons/com/atproto/space/getSpace.defs.d.ts.map +1 -0
  203. package/dist/lexicons/com/atproto/space/getSpace.defs.js +17 -0
  204. package/dist/lexicons/com/atproto/space/getSpace.defs.js.map +1 -0
  205. package/dist/lexicons/com/atproto/space/getSpace.js +6 -0
  206. package/dist/lexicons/com/atproto/space/getSpace.js.map +1 -0
  207. package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts +3 -0
  208. package/dist/lexicons/com/atproto/space/getSpaceCredential.d.ts.map +1 -0
  209. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts +53 -0
  210. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.d.ts.map +1 -0
  211. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js +17 -0
  212. package/dist/lexicons/com/atproto/space/getSpaceCredential.defs.js.map +1 -0
  213. package/dist/lexicons/com/atproto/space/getSpaceCredential.js +6 -0
  214. package/dist/lexicons/com/atproto/space/getSpaceCredential.js.map +1 -0
  215. package/dist/lexicons/com/atproto/space/listBlobs.d.ts +3 -0
  216. package/dist/lexicons/com/atproto/space/listBlobs.d.ts.map +1 -0
  217. package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts +44 -0
  218. package/dist/lexicons/com/atproto/space/listBlobs.defs.d.ts.map +1 -0
  219. package/dist/lexicons/com/atproto/space/listBlobs.defs.js +14 -0
  220. package/dist/lexicons/com/atproto/space/listBlobs.defs.js.map +1 -0
  221. package/dist/lexicons/com/atproto/space/listBlobs.js +6 -0
  222. package/dist/lexicons/com/atproto/space/listBlobs.js.map +1 -0
  223. package/dist/lexicons/com/atproto/space/listRecords.d.ts +3 -0
  224. package/dist/lexicons/com/atproto/space/listRecords.d.ts.map +1 -0
  225. package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts +58 -0
  226. package/dist/lexicons/com/atproto/space/listRecords.defs.d.ts.map +1 -0
  227. package/dist/lexicons/com/atproto/space/listRecords.defs.js +16 -0
  228. package/dist/lexicons/com/atproto/space/listRecords.defs.js.map +1 -0
  229. package/dist/lexicons/com/atproto/space/listRecords.js +6 -0
  230. package/dist/lexicons/com/atproto/space/listRecords.js.map +1 -0
  231. package/dist/lexicons/com/atproto/space/listRepoOps.d.ts +3 -0
  232. package/dist/lexicons/com/atproto/space/listRepoOps.d.ts.map +1 -0
  233. package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts +74 -0
  234. package/dist/lexicons/com/atproto/space/listRepoOps.defs.d.ts.map +1 -0
  235. package/dist/lexicons/com/atproto/space/listRepoOps.defs.js +18 -0
  236. package/dist/lexicons/com/atproto/space/listRepoOps.defs.js.map +1 -0
  237. package/dist/lexicons/com/atproto/space/listRepoOps.js +6 -0
  238. package/dist/lexicons/com/atproto/space/listRepoOps.js.map +1 -0
  239. package/dist/lexicons/com/atproto/space/listSpaces.d.ts +3 -0
  240. package/dist/lexicons/com/atproto/space/listSpaces.d.ts.map +1 -0
  241. package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts +59 -0
  242. package/dist/lexicons/com/atproto/space/listSpaces.defs.d.ts.map +1 -0
  243. package/dist/lexicons/com/atproto/space/listSpaces.defs.js +16 -0
  244. package/dist/lexicons/com/atproto/space/listSpaces.defs.js.map +1 -0
  245. package/dist/lexicons/com/atproto/space/listSpaces.js +6 -0
  246. package/dist/lexicons/com/atproto/space/listSpaces.js.map +1 -0
  247. package/dist/lexicons/com/atproto/space/listWriters.d.ts +3 -0
  248. package/dist/lexicons/com/atproto/space/listWriters.d.ts.map +1 -0
  249. package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts +35 -0
  250. package/dist/lexicons/com/atproto/space/listWriters.defs.d.ts.map +1 -0
  251. package/dist/lexicons/com/atproto/space/listWriters.defs.js +15 -0
  252. package/dist/lexicons/com/atproto/space/listWriters.defs.js.map +1 -0
  253. package/dist/lexicons/com/atproto/space/listWriters.js +6 -0
  254. package/dist/lexicons/com/atproto/space/listWriters.js.map +1 -0
  255. package/dist/lexicons/com/atproto/space/putRecord.d.ts +3 -0
  256. package/dist/lexicons/com/atproto/space/putRecord.d.ts.map +1 -0
  257. package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts +69 -0
  258. package/dist/lexicons/com/atproto/space/putRecord.defs.d.ts.map +1 -0
  259. package/dist/lexicons/com/atproto/space/putRecord.defs.js +15 -0
  260. package/dist/lexicons/com/atproto/space/putRecord.defs.js.map +1 -0
  261. package/dist/lexicons/com/atproto/space/putRecord.js +6 -0
  262. package/dist/lexicons/com/atproto/space/putRecord.js.map +1 -0
  263. package/dist/lexicons/com/atproto/space/registerNotify.d.ts +3 -0
  264. package/dist/lexicons/com/atproto/space/registerNotify.d.ts.map +1 -0
  265. package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts +37 -0
  266. package/dist/lexicons/com/atproto/space/registerNotify.defs.d.ts.map +1 -0
  267. package/dist/lexicons/com/atproto/space/registerNotify.defs.js +23 -0
  268. package/dist/lexicons/com/atproto/space/registerNotify.defs.js.map +1 -0
  269. package/dist/lexicons/com/atproto/space/registerNotify.js +6 -0
  270. package/dist/lexicons/com/atproto/space/registerNotify.js.map +1 -0
  271. package/dist/lexicons/com/atproto/space/removeWriter.d.ts +3 -0
  272. package/dist/lexicons/com/atproto/space/removeWriter.d.ts.map +1 -0
  273. package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts +33 -0
  274. package/dist/lexicons/com/atproto/space/removeWriter.defs.d.ts.map +1 -0
  275. package/dist/lexicons/com/atproto/space/removeWriter.defs.js +15 -0
  276. package/dist/lexicons/com/atproto/space/removeWriter.defs.js.map +1 -0
  277. package/dist/lexicons/com/atproto/space/removeWriter.js +6 -0
  278. package/dist/lexicons/com/atproto/space/removeWriter.js.map +1 -0
  279. package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts +3 -0
  280. package/dist/lexicons/com/atproto/space/unregisterNotify.d.ts.map +1 -0
  281. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts +29 -0
  282. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.d.ts.map +1 -0
  283. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js +20 -0
  284. package/dist/lexicons/com/atproto/space/unregisterNotify.defs.js.map +1 -0
  285. package/dist/lexicons/com/atproto/space/unregisterNotify.js +6 -0
  286. package/dist/lexicons/com/atproto/space/unregisterNotify.js.map +1 -0
  287. package/dist/lexicons/com/atproto/space/updateSpace.d.ts +3 -0
  288. package/dist/lexicons/com/atproto/space/updateSpace.d.ts.map +1 -0
  289. package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts +32 -0
  290. package/dist/lexicons/com/atproto/space/updateSpace.defs.d.ts.map +1 -0
  291. package/dist/lexicons/com/atproto/space/updateSpace.defs.js +18 -0
  292. package/dist/lexicons/com/atproto/space/updateSpace.defs.js.map +1 -0
  293. package/dist/lexicons/com/atproto/space/updateSpace.js +6 -0
  294. package/dist/lexicons/com/atproto/space/updateSpace.js.map +1 -0
  295. package/dist/lexicons/com/atproto/space.d.ts +23 -0
  296. package/dist/lexicons/com/atproto/space.d.ts.map +1 -0
  297. package/dist/lexicons/com/atproto/space.js +26 -0
  298. package/dist/lexicons/com/atproto/space.js.map +1 -0
  299. package/dist/lexicons/com/atproto.d.ts +5 -0
  300. package/dist/lexicons/com/atproto.d.ts.map +1 -0
  301. package/dist/lexicons/com/atproto.js +8 -0
  302. package/dist/lexicons/com/atproto.js.map +1 -0
  303. package/dist/lexicons/com.d.ts +2 -0
  304. package/dist/lexicons/com.d.ts.map +1 -0
  305. package/dist/lexicons/com.js +5 -0
  306. package/dist/lexicons/com.js.map +1 -0
  307. package/dist/lexicons/index.d.ts +2 -0
  308. package/dist/lexicons/index.d.ts.map +1 -0
  309. package/dist/lexicons/index.js +5 -0
  310. package/dist/lexicons/index.js.map +1 -0
  311. package/dist/policies/baseline.d.ts +7 -0
  312. package/dist/policies/baseline.d.ts.map +1 -0
  313. package/dist/policies/baseline.js +10 -0
  314. package/dist/policies/baseline.js.map +1 -0
  315. package/dist/policies/index.d.ts +6 -0
  316. package/dist/policies/index.d.ts.map +1 -0
  317. package/dist/policies/index.js +6 -0
  318. package/dist/policies/index.js.map +1 -0
  319. package/dist/policies/managedspace.d.ts +12 -0
  320. package/dist/policies/managedspace.d.ts.map +1 -0
  321. package/dist/policies/managedspace.js +12 -0
  322. package/dist/policies/managedspace.js.map +1 -0
  323. package/dist/policies/memberspace.d.ts +31 -0
  324. package/dist/policies/memberspace.d.ts.map +1 -0
  325. package/dist/policies/memberspace.js +48 -0
  326. package/dist/policies/memberspace.js.map +1 -0
  327. package/dist/policies/personalspace.d.ts +11 -0
  328. package/dist/policies/personalspace.d.ts.map +1 -0
  329. package/dist/policies/personalspace.js +11 -0
  330. package/dist/policies/personalspace.js.map +1 -0
  331. package/dist/policies/space-policy-manager.d.ts +73 -0
  332. package/dist/policies/space-policy-manager.d.ts.map +1 -0
  333. package/dist/policies/space-policy-manager.js +81 -0
  334. package/dist/policies/space-policy-manager.js.map +1 -0
  335. package/dist/space-client.d.ts +254 -0
  336. package/dist/space-client.d.ts.map +1 -0
  337. package/dist/space-client.js +301 -0
  338. package/dist/space-client.js.map +1 -0
  339. package/dist/space-collection.d.ts +11 -0
  340. package/dist/space-collection.d.ts.map +1 -0
  341. package/dist/space-collection.js +2 -0
  342. package/dist/space-collection.js.map +1 -0
  343. package/dist/space-credential-provider.d.ts +68 -0
  344. package/dist/space-credential-provider.d.ts.map +1 -0
  345. package/dist/space-credential-provider.js +68 -0
  346. package/dist/space-credential-provider.js.map +1 -0
  347. package/dist/space-credential.d.ts +35 -0
  348. package/dist/space-credential.d.ts.map +1 -0
  349. package/dist/space-credential.js +64 -0
  350. package/dist/space-credential.js.map +1 -0
  351. package/dist/space-manager.d.ts +102 -0
  352. package/dist/space-manager.d.ts.map +1 -0
  353. package/dist/space-manager.js +121 -0
  354. package/dist/space-manager.js.map +1 -0
  355. package/dist/space-reader.d.ts +400 -0
  356. package/dist/space-reader.d.ts.map +1 -0
  357. package/dist/space-reader.js +573 -0
  358. package/dist/space-reader.js.map +1 -0
  359. package/dist/write-operation-builder.d.ts +22 -0
  360. package/dist/write-operation-builder.d.ts.map +1 -0
  361. package/dist/write-operation-builder.js +37 -0
  362. package/dist/write-operation-builder.js.map +1 -0
  363. package/package.json +64 -3
@@ -0,0 +1,254 @@
1
+ import { type AccountAgent, type Agent, type DidString, type Infer, type InferMethodInputBody, type InferMethodOutputBody, type LexMap, type Main, type NsidString, type Procedure, type Query, type RecordKeyOptions, type Restricted, type XrpcOptions, type XrpcResponse } from '@atproto/lex-client';
2
+ import type { TypedLexMap } from '@atproto/lex-data';
3
+ import { type RecordKeyValue, type RecordSchema, type Space } from '@atproto/lex-schema';
4
+ import { SpaceRef, type SpaceRefString } from '@atproto/syntax';
5
+ import { main as applyWrites } from './lexicons/com/atproto/space/applyWrites.js';
6
+ import { main as clearRecords } from './lexicons/com/atproto/space/clearRecords.js';
7
+ import { main as createRecord } from './lexicons/com/atproto/space/createRecord.js';
8
+ import { main as createSpace } from './lexicons/com/atproto/space/createSpace.js';
9
+ import { main as deleteRecord } from './lexicons/com/atproto/space/deleteRecord.js';
10
+ import type { main as getBlob } from './lexicons/com/atproto/space/getBlob.js';
11
+ import { main as getRecord } from './lexicons/com/atproto/space/getRecord.js';
12
+ import type { main as listBlobs } from './lexicons/com/atproto/space/listBlobs.js';
13
+ import type { main as listRecords } from './lexicons/com/atproto/space/listRecords.js';
14
+ import { main as putRecord } from './lexicons/com/atproto/space/putRecord.js';
15
+ import type { SpaceCollectionSchema } from './space-collection.js';
16
+ import { SpaceReader } from './space-reader.js';
17
+ import { SpaceWriteOperationHelper } from './write-operation-builder.js';
18
+ export * from './space-reader.js';
19
+ export type { AccountAgent, Agent, Space, SpaceRefString, SpaceWriteOperationHelper, };
20
+ export declare namespace SpaceClient {
21
+ type WriteOperation = SpaceWriteOperationHelper.Operation;
22
+ type WriteOperationsFactory = SpaceWriteOperationHelper.Factory;
23
+ type Options = Omit<SpaceReader.Options, 'delegationTokenProvider'>;
24
+ type CreateSpaceOptions = Options & {
25
+ signal?: AbortSignal;
26
+ };
27
+ type OpenSpaceOptions = Options & {
28
+ agent: Agent;
29
+ };
30
+ type CreateSpaceInput<S extends Space> = {
31
+ /** The policy governing the space. */
32
+ policy: InferMethodInputBody<typeof createSpace>['policy'];
33
+ } & (S['key'] extends 'nsid' ? {
34
+ skey: NsidString;
35
+ } : {
36
+ /**
37
+ * The space key. Defaults to the space type's literal key, or else to a
38
+ * TID generated by the PDS.
39
+ */
40
+ skey?: RecordKeyValue<S['key']>;
41
+ });
42
+ /**
43
+ * Selects which account's repo, within the space, a read targets. Defaults to
44
+ * the authenticated user's.
45
+ */
46
+ type RepoOptions = {
47
+ repo?: DidString;
48
+ };
49
+ type ListRecordsOptions = Omit<SpaceReader.ListRecordsOptions, 'repo'> & RepoOptions;
50
+ type GetRecordOptions = Omit<SpaceReader.GetRecordOptions, 'repo'> & RepoOptions;
51
+ type GetBlobOptions = Omit<SpaceReader.GetBlobOptions, 'repo'> & RepoOptions;
52
+ type ListBlobsOptions = Omit<SpaceReader.ListBlobsOptions, 'repo'> & RepoOptions;
53
+ type CreateRecordOptions = Omit<XrpcOptions<typeof createRecord>, 'body' | 'service' | 'labelers'> & {
54
+ /** Tri-state server-side validation, as in `Client.createRecord()`. */
55
+ validate?: boolean;
56
+ };
57
+ type PutRecordOptions = Omit<XrpcOptions<typeof putRecord>, 'body' | 'service' | 'labelers'> & {
58
+ /** Tri-state server-side validation, as in `Client.putRecord()`. */
59
+ validate?: boolean;
60
+ };
61
+ type DeleteRecordOptions = Omit<XrpcOptions<typeof deleteRecord>, 'body' | 'service' | 'labelers'>;
62
+ type ApplyWritesOptions = Omit<XrpcOptions<typeof applyWrites>, 'body' | 'service' | 'labelers'> & {
63
+ /** Tri-state server-side validation, as in `Client.applyWrites()`. */
64
+ validate?: boolean;
65
+ };
66
+ type ClearRecordsOptions = Omit<XrpcOptions<typeof clearRecords>, 'body' | 'service' | 'labelers'>;
67
+ type CreateOptions<T extends RecordSchema> = CreateRecordOptions & RecordKeyOptions<T, 'tid' | 'any'>;
68
+ type PutOptions<T extends RecordSchema> = PutRecordOptions & RecordKeyOptions<T>;
69
+ type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions & RecordKeyOptions<T>;
70
+ type GetOptions<T extends RecordSchema> = GetRecordOptions & RecordKeyOptions<T>;
71
+ type ListOptions = Omit<ListRecordsOptions, 'collection' | 'excludeValues'>;
72
+ type WriteOutput = InferMethodOutputBody<typeof createRecord, Uint8Array>;
73
+ type GetOutput<T extends RecordSchema> = Omit<InferMethodOutputBody<typeof getRecord, Uint8Array>, 'value'> & {
74
+ value: Infer<T>;
75
+ };
76
+ type ListOutput<T extends RecordSchema> = Omit<InferMethodOutputBody<typeof listRecords>, 'records'> & {
77
+ /** Every listed record, flagged with whether it matched the schema. */
78
+ records: ListRecordItem<Infer<T>>[];
79
+ };
80
+ type ListRecordItem<Value extends LexMap> = Omit<SpaceReader.ListedRecord, 'value'> & ({
81
+ valid: true;
82
+ value: Value;
83
+ } | {
84
+ valid: false;
85
+ value?: LexMap;
86
+ });
87
+ }
88
+ /**
89
+ * Reads and writes a space on behalf of a user, through their agent (e.g. their
90
+ * OAuth session).
91
+ *
92
+ * Requests are routed by the repo they target, per the protocol's audience
93
+ * rule:
94
+ * - the user's own repo: their PDS, with their agent. This includes every
95
+ * write, as only the user's own repo can be written to.
96
+ * - another account's repo: that account's PDS, with the space credential
97
+ * presented to that account.
98
+ * - no repo (e.g. `listWriters`): the space host, with the space credential
99
+ * presented to the space authority.
100
+ *
101
+ * The space credential is obtained the first time a request needs one, from a
102
+ * delegation token issued by the user's PDS (which requires a `read` grant on
103
+ * the space), and renewed shortly before it expires. Requests to the user's
104
+ * own repo never need one, so a `read_self` grant is enough for those. Each
105
+ * instance obtains its own credential: keep one instance per space to reuse
106
+ * it.
107
+ *
108
+ * The typed reads and writes (`create()`, `get()`, `list()`, …) only accept
109
+ * the collections declared by the space type, unless `validateRequest` is
110
+ * `false` (with `validateRequest: true`, records are also validated against
111
+ * their schema before being written). The lower level methods
112
+ * (`createRecord()`, …) accept any record.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const space = SpaceClient.openSpace(com.example.forum, spaceUri, {
117
+ * agent: client.agent,
118
+ * })
119
+ *
120
+ * for await (const { $type, repo } of space.writers()) {
121
+ * if ($type !== 'com.atproto.space.defs#repoWrite') continue // removed
122
+ * const { records } = await space.list(com.example.post, { repo })
123
+ * }
124
+ * ```
125
+ */
126
+ export declare class SpaceClient<S extends Space = Space> extends SpaceReader<S> {
127
+ /** The user's agent (e.g. their OAuth session). */
128
+ readonly agent: AccountAgent;
129
+ /**
130
+ * Opens a space for the user of `agent`. No request is made until the space
131
+ * is used.
132
+ *
133
+ * @throws {TypeError} if `agent` is not authenticated, or if the space is not
134
+ * of the type described by `schema`
135
+ */
136
+ static openSpace<const S extends Space>(schema: S, space: SpaceRefString | SpaceRef | SpaceReader.AuthorityRef<S>, { agent, ...options }: SpaceClient.OpenSpaceOptions): SpaceClient<S>;
137
+ /**
138
+ * Creates a space of the type described by `schema`, with the user of
139
+ * `agent` as its authority, and opens it.
140
+ *
141
+ * @throws {XrpcResponseError} with `SpaceAlreadyExists` if the user already
142
+ * has a space of that type and key, or `UnsupportedPolicy` if their PDS does
143
+ * not implement the policy
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const space = await SpaceClient.createSpace(client.agent, com.example.forum, {
148
+ * skey: 'general',
149
+ * policy: memberspace.policy.$build({}),
150
+ * })
151
+ * ```
152
+ */
153
+ static createSpace<const S extends Space>(agent: Agent, schema: S, { policy, skey }: SpaceClient.CreateSpaceInput<S>, { signal, ...options }?: SpaceClient.CreateSpaceOptions): Promise<SpaceClient<S>>;
154
+ /**
155
+ * @throws {TypeError} if the space is not of the type described by `schema`
156
+ */
157
+ constructor(
158
+ /** The user's agent (e.g. their OAuth session). */
159
+ agent: AccountAgent, schema: S, ref: SpaceRef, options?: SpaceClient.Options);
160
+ /** The DID of the authenticated user. */
161
+ get did(): DidString;
162
+ /**
163
+ * Makes an XRPC request to the host (PDS) of a repo in the space: with the
164
+ * user's agent for their own repo, and with the space credential otherwise.
165
+ */
166
+ protected repoXrpc<const M extends Query | Procedure>(repo: DidString, ns: Main<M>, options: XrpcOptions<M>): Promise<XrpcResponse<M>>;
167
+ listRecords({ repo, ...options }?: SpaceClient.ListRecordsOptions): Promise<XrpcResponse<typeof listRecords>>;
168
+ records({ repo, ...options }?: SpaceClient.ListRecordsOptions): AsyncGenerator<SpaceReader.ListedRecord, void, undefined>;
169
+ /**
170
+ * Gets a record. When read from another account's repo, the record is
171
+ * verified against the MAC its host computed for this request.
172
+ *
173
+ * @throws {SpaceRepoVerificationError} if the record fails verification
174
+ */
175
+ getRecord(collection: NsidString, rkey: string, { repo, ...options }?: SpaceClient.GetRecordOptions): Promise<XrpcResponse<typeof getRecord>>;
176
+ getBlob({ repo, ...options }: SpaceClient.GetBlobOptions): Promise<XrpcResponse<typeof getBlob>>;
177
+ listBlobs({ repo, ...options }?: SpaceClient.ListBlobsOptions): Promise<XrpcResponse<typeof listBlobs>>;
178
+ createRecord(record: TypedLexMap<NsidString>, rkey?: string, { validate, ...options }?: SpaceClient.CreateRecordOptions): Promise<XrpcResponse<typeof createRecord>>;
179
+ putRecord(record: TypedLexMap<NsidString>, rkey: string, { validate, ...options }?: SpaceClient.PutRecordOptions): Promise<XrpcResponse<typeof putRecord>>;
180
+ deleteRecord(collection: NsidString, rkey: string, options?: SpaceClient.DeleteRecordOptions): Promise<XrpcResponse<typeof deleteRecord>>;
181
+ /**
182
+ * Applies a batch of writes to the user's repo in the space, atomically.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * await space.applyWrites((op) => [
187
+ * op.create(com.example.post, { text: 'Hello' }),
188
+ * op.delete(com.example.post, { rkey: '3jxf7z2k3q2' }),
189
+ * ])
190
+ * ```
191
+ */
192
+ applyWrites(factory: SpaceClient.WriteOperationsFactory, { validate, ...options }?: SpaceClient.ApplyWritesOptions): Promise<XrpcResponse<typeof applyWrites>>;
193
+ /** Deletes every record in the user's repo in the space. */
194
+ clearRecords(options?: SpaceClient.ClearRecordsOptions): Promise<XrpcResponse<typeof clearRecords>>;
195
+ /**
196
+ * Creates a record in the user's repo in the space, as `Client.create()`
197
+ * does in their public repo.
198
+ */
199
+ create<const T extends RecordSchema>(ns: NonNullable<unknown> extends SpaceClient.CreateOptions<T> ? SpaceCollectionSchema<S, T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<SpaceClient.WriteOutput>;
200
+ create<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, input: Omit<Infer<T>, '$type'>, options: SpaceClient.CreateOptions<T>): Promise<SpaceClient.WriteOutput>;
201
+ create<const T extends RecordSchema>(ns: Main<T>, input: Omit<Infer<T>, '$type'>, options: SpaceClient.CreateOptions<T> & {
202
+ validateRequest: false;
203
+ }): Promise<SpaceClient.WriteOutput>;
204
+ /**
205
+ * Creates or updates a record in the user's repo in the space, as
206
+ * `Client.put()` does in their public repo.
207
+ */
208
+ put<const T extends RecordSchema>(ns: NonNullable<unknown> extends SpaceClient.PutOptions<T> ? SpaceCollectionSchema<S, T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<SpaceClient.WriteOutput>;
209
+ put<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, input: Omit<Infer<T>, '$type'>, options: SpaceClient.PutOptions<T>): Promise<SpaceClient.WriteOutput>;
210
+ put<const T extends RecordSchema>(ns: Main<T>, input: Omit<Infer<T>, '$type'>, options: SpaceClient.PutOptions<T> & {
211
+ validateRequest: false;
212
+ }): Promise<SpaceClient.WriteOutput>;
213
+ /** Deletes a record from the user's repo in the space. */
214
+ delete<const T extends RecordSchema>(ns: NonNullable<unknown> extends SpaceClient.DeleteOptions<T> ? SpaceCollectionSchema<S, T> : Restricted<'This record type requires an "options" argument'>): Promise<void>;
215
+ delete<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, options: SpaceClient.DeleteOptions<T>): Promise<void>;
216
+ delete<const T extends RecordSchema>(ns: Main<T>, options: SpaceClient.DeleteOptions<T> & {
217
+ validateRequest: false;
218
+ }): Promise<void>;
219
+ /**
220
+ * Gets a record, validated against its schema. Reads the user's own repo
221
+ * unless `options.repo` is set.
222
+ */
223
+ get<const T extends RecordSchema>(ns: T['key'] extends `literal:${string}` ? SpaceCollectionSchema<S, T> : Restricted<'This record type requires an "options" argument'>): Promise<SpaceClient.GetOutput<T>>;
224
+ get<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, options: SpaceClient.GetOptions<T>): Promise<SpaceClient.GetOutput<T>>;
225
+ get<const T extends RecordSchema>(ns: Main<T>, options: SpaceClient.GetOptions<T> & {
226
+ validateRequest: false;
227
+ }): Promise<SpaceClient.GetOutput<T>>;
228
+ /**
229
+ * Lists a collection's records, each validated against its schema. Lists
230
+ * the user's own repo unless `options.repo` is set.
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * const { records, cursor } = await space.list(com.example.post, { repo })
235
+ * for (const record of records) {
236
+ * if (record.valid) record.value // com.example.post.Main
237
+ * }
238
+ * ```
239
+ */
240
+ list<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, options?: SpaceClient.ListOptions): Promise<SpaceClient.ListOutput<T>>;
241
+ list<const T extends RecordSchema>(ns: Main<T>, options: SpaceClient.ListOptions & {
242
+ validateRequest: false;
243
+ }): Promise<SpaceClient.ListOutput<T>>;
244
+ /**
245
+ * Iterates over a collection's records, each validated against its schema,
246
+ * handling pagination. Lists the user's own repo unless `options.repo` is
247
+ * set.
248
+ */
249
+ listAll<const T extends RecordSchema>(ns: SpaceCollectionSchema<S, T>, options?: SpaceClient.ListOptions): AsyncGenerator<SpaceClient.ListRecordItem<Infer<T>>, void, undefined>;
250
+ listAll<const T extends RecordSchema>(ns: Main<T>, options: SpaceClient.ListOptions & {
251
+ validateRequest: false;
252
+ }): AsyncGenerator<SpaceClient.ListRecordItem<Infer<T>>, void, undefined>;
253
+ }
254
+ //# sourceMappingURL=space-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-client.d.ts","sourceRoot":"","sources":["../src/space-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EAKlB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EAEX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,8CAA8C,CAAA;AACnF,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,8CAA8C,CAAA;AACnF,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,8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AA;CAczE"}
@@ -0,0 +1,301 @@
1
+ import { isAccountAgent, rkeyFor, rkeyForCreate, xrpc, } from '@atproto/lex-client';
2
+ import { getMain, } from '@atproto/lex-schema';
3
+ import { SpaceRef } from '@atproto/syntax';
4
+ import { delegationTokenProviderFor } from './delegation-token-provider.js';
5
+ import { main as applyWrites } from './lexicons/com/atproto/space/applyWrites.js';
6
+ import { main as clearRecords } from './lexicons/com/atproto/space/clearRecords.js';
7
+ import { main as createRecord } from './lexicons/com/atproto/space/createRecord.js';
8
+ import { main as createSpace } from './lexicons/com/atproto/space/createSpace.js';
9
+ import { main as deleteRecord } from './lexicons/com/atproto/space/deleteRecord.js';
10
+ import { main as getRecord } from './lexicons/com/atproto/space/getRecord.js';
11
+ import { main as putRecord } from './lexicons/com/atproto/space/putRecord.js';
12
+ import { SpaceReader } from './space-reader.js';
13
+ import { SpaceWriteOperationHelper } from './write-operation-builder.js';
14
+ export * from './space-reader.js';
15
+ /**
16
+ * Reads and writes a space on behalf of a user, through their agent (e.g. their
17
+ * OAuth session).
18
+ *
19
+ * Requests are routed by the repo they target, per the protocol's audience
20
+ * rule:
21
+ * - the user's own repo: their PDS, with their agent. This includes every
22
+ * write, as only the user's own repo can be written to.
23
+ * - another account's repo: that account's PDS, with the space credential
24
+ * presented to that account.
25
+ * - no repo (e.g. `listWriters`): the space host, with the space credential
26
+ * presented to the space authority.
27
+ *
28
+ * The space credential is obtained the first time a request needs one, from a
29
+ * delegation token issued by the user's PDS (which requires a `read` grant on
30
+ * the space), and renewed shortly before it expires. Requests to the user's
31
+ * own repo never need one, so a `read_self` grant is enough for those. Each
32
+ * instance obtains its own credential: keep one instance per space to reuse
33
+ * it.
34
+ *
35
+ * The typed reads and writes (`create()`, `get()`, `list()`, …) only accept
36
+ * the collections declared by the space type, unless `validateRequest` is
37
+ * `false` (with `validateRequest: true`, records are also validated against
38
+ * their schema before being written). The lower level methods
39
+ * (`createRecord()`, …) accept any record.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const space = SpaceClient.openSpace(com.example.forum, spaceUri, {
44
+ * agent: client.agent,
45
+ * })
46
+ *
47
+ * for await (const { $type, repo } of space.writers()) {
48
+ * if ($type !== 'com.atproto.space.defs#repoWrite') continue // removed
49
+ * const { records } = await space.list(com.example.post, { repo })
50
+ * }
51
+ * ```
52
+ */
53
+ export class SpaceClient extends SpaceReader {
54
+ /**
55
+ * Opens a space for the user of `agent`. No request is made until the space
56
+ * is used.
57
+ *
58
+ * @throws {TypeError} if `agent` is not authenticated, or if the space is not
59
+ * of the type described by `schema`
60
+ */
61
+ static openSpace(schema, space, { agent, ...options }) {
62
+ if (!isAccountAgent(agent)) {
63
+ throw new TypeError('Agent must be authenticated');
64
+ }
65
+ const ref = typeof space === 'string'
66
+ ? SpaceRef.parse(space)
67
+ : space instanceof SpaceRef
68
+ ? space
69
+ : schema.spaceRefFor(space.authority, space.skey);
70
+ return new SpaceClient(agent, schema, ref, options);
71
+ }
72
+ /**
73
+ * Creates a space of the type described by `schema`, with the user of
74
+ * `agent` as its authority, and opens it.
75
+ *
76
+ * @throws {XrpcResponseError} with `SpaceAlreadyExists` if the user already
77
+ * has a space of that type and key, or `UnsupportedPolicy` if their PDS does
78
+ * not implement the policy
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const space = await SpaceClient.createSpace(client.agent, com.example.forum, {
83
+ * skey: 'general',
84
+ * policy: memberspace.policy.$build({}),
85
+ * })
86
+ * ```
87
+ */
88
+ static async createSpace(agent, schema, { policy, skey }, { signal, ...options } = {}) {
89
+ if (!isAccountAgent(agent)) {
90
+ throw new TypeError('Agent must be authenticated');
91
+ }
92
+ // Validates the key, and defaults it for literal keys
93
+ const ref = skey != null || schema.key.startsWith('literal:')
94
+ ? schema.spaceRefFor(agent.did, skey)
95
+ : undefined;
96
+ const { body } = await xrpc(agent, createSpace, {
97
+ signal,
98
+ body: { spaceType: schema.nsid, skey: ref?.skey, policy },
99
+ });
100
+ return new SpaceClient(agent, schema, SpaceRef.parse(body.space), options);
101
+ }
102
+ /**
103
+ * @throws {TypeError} if the space is not of the type described by `schema`
104
+ */
105
+ constructor(
106
+ /** The user's agent (e.g. their OAuth session). */
107
+ agent, schema, ref, options = {}) {
108
+ super(schema, ref, {
109
+ ...options,
110
+ delegationTokenProvider: delegationTokenProviderFor(agent),
111
+ });
112
+ this.agent = agent;
113
+ }
114
+ /** The DID of the authenticated user. */
115
+ get did() {
116
+ return this.agent.did;
117
+ }
118
+ /**
119
+ * Makes an XRPC request to the host (PDS) of a repo in the space: with the
120
+ * user's agent for their own repo, and with the space credential otherwise.
121
+ */
122
+ async repoXrpc(repo, ns, options) {
123
+ // Override, use the agent directly for the user's own repo.
124
+ if (repo === this.did) {
125
+ return xrpc(this.agent, ns, options);
126
+ }
127
+ return super.repoXrpc(repo, ns, options);
128
+ }
129
+ async listRecords({ repo = this.did, ...options } = {}) {
130
+ return super.listRecords({ ...options, repo });
131
+ }
132
+ records({ repo = this.did, ...options } = {}) {
133
+ return super.records({ ...options, repo });
134
+ }
135
+ /**
136
+ * Gets a record. When read from another account's repo, the record is
137
+ * verified against the MAC its host computed for this request.
138
+ *
139
+ * @throws {SpaceRepoVerificationError} if the record fails verification
140
+ */
141
+ async getRecord(collection, rkey, { repo = this.did, ...options } = {}) {
142
+ if (repo === this.did) {
143
+ return xrpc(this.agent, getRecord, {
144
+ ...options,
145
+ service: null,
146
+ labelers: null,
147
+ params: { space: this.uri, repo, collection, rkey },
148
+ });
149
+ }
150
+ return super.getRecord(collection, rkey, { ...options, repo });
151
+ }
152
+ async getBlob({ repo = this.did, ...options }) {
153
+ return super.getBlob({ ...options, repo });
154
+ }
155
+ async listBlobs({ repo = this.did, ...options } = {}) {
156
+ return super.listBlobs({ ...options, repo });
157
+ }
158
+ async createRecord(record, rkey, { validate, ...options } = {}) {
159
+ return xrpc(this.agent, createRecord, {
160
+ ...options,
161
+ service: null,
162
+ labelers: null,
163
+ body: {
164
+ space: this.uri,
165
+ repo: this.did,
166
+ collection: record.$type,
167
+ rkey,
168
+ validate,
169
+ record,
170
+ },
171
+ });
172
+ }
173
+ async putRecord(record, rkey, { validate, ...options } = {}) {
174
+ return xrpc(this.agent, putRecord, {
175
+ ...options,
176
+ service: null,
177
+ labelers: null,
178
+ body: {
179
+ space: this.uri,
180
+ repo: this.did,
181
+ collection: record.$type,
182
+ rkey,
183
+ validate,
184
+ record,
185
+ },
186
+ });
187
+ }
188
+ async deleteRecord(collection, rkey, options = {}) {
189
+ return xrpc(this.agent, deleteRecord, {
190
+ ...options,
191
+ service: null,
192
+ labelers: null,
193
+ body: { space: this.uri, repo: this.did, collection, rkey },
194
+ });
195
+ }
196
+ /**
197
+ * Applies a batch of writes to the user's repo in the space, atomically.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * await space.applyWrites((op) => [
202
+ * op.create(com.example.post, { text: 'Hello' }),
203
+ * op.delete(com.example.post, { rkey: '3jxf7z2k3q2' }),
204
+ * ])
205
+ * ```
206
+ */
207
+ async applyWrites(factory, { validate, ...options } = {}) {
208
+ return xrpc(this.agent, applyWrites, {
209
+ ...options,
210
+ service: null,
211
+ labelers: null,
212
+ body: {
213
+ space: this.uri,
214
+ repo: this.did,
215
+ validate,
216
+ writes: SpaceWriteOperationHelper.build(factory),
217
+ },
218
+ });
219
+ }
220
+ /** Deletes every record in the user's repo in the space. */
221
+ async clearRecords(options = {}) {
222
+ return xrpc(this.agent, clearRecords, {
223
+ ...options,
224
+ service: null,
225
+ labelers: null,
226
+ body: { space: this.uri, repo: this.did },
227
+ });
228
+ }
229
+ async create(ns, input, options = {}) {
230
+ const schema = getMain(ns);
231
+ if (options.validateRequest !== false)
232
+ this.assertCollection(schema.$type);
233
+ const record = schema.build(input);
234
+ if (options.validateRequest)
235
+ schema.validate(record);
236
+ const rkey = rkeyForCreate(schema, options.rkey);
237
+ if (rkey !== undefined)
238
+ schema.keySchema.assert(rkey);
239
+ const response = await this.createRecord(record, rkey, options);
240
+ return response.body;
241
+ }
242
+ async put(ns, input, options = {}) {
243
+ const schema = getMain(ns);
244
+ if (options.validateRequest !== false)
245
+ this.assertCollection(schema.$type);
246
+ const record = schema.build(input);
247
+ if (options.validateRequest)
248
+ schema.validate(record);
249
+ const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey));
250
+ const response = await this.putRecord(record, rkey, options);
251
+ return response.body;
252
+ }
253
+ async delete(ns, options = {}) {
254
+ const schema = getMain(ns);
255
+ if (options.validateRequest !== false)
256
+ this.assertCollection(schema.$type);
257
+ const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey));
258
+ await this.deleteRecord(schema.$type, rkey, options);
259
+ }
260
+ async get(ns, options = {}) {
261
+ const schema = getMain(ns);
262
+ if (options.validateRequest !== false)
263
+ this.assertCollection(schema.$type);
264
+ const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey));
265
+ const response = await this.getRecord(schema.$type, rkey, options);
266
+ const value = schema.validate(response.body.value);
267
+ return { ...response.body, value };
268
+ }
269
+ async list(ns, options = {}) {
270
+ const schema = getMain(ns);
271
+ if (options.validateRequest !== false)
272
+ this.assertCollection(schema.$type);
273
+ const { body } = await this.listRecords({
274
+ ...options,
275
+ collection: schema.$type,
276
+ });
277
+ const records = body.records.map(processListRecord, schema);
278
+ return { ...body, records };
279
+ }
280
+ async *listAll(ns, options = {}) {
281
+ const schema = getMain(ns);
282
+ if (options.validateRequest !== false)
283
+ this.assertCollection(schema.$type);
284
+ for await (const record of this.records({
285
+ ...options,
286
+ collection: schema.$type,
287
+ })) {
288
+ yield processListRecord.call(schema, record);
289
+ }
290
+ }
291
+ }
292
+ function processListRecord(record) {
293
+ const result = this.safeValidate(record.value);
294
+ if (result.success) {
295
+ return { ...record, valid: true, value: result.value };
296
+ }
297
+ else {
298
+ return { ...record, valid: false };
299
+ }
300
+ }
301
+ //# sourceMappingURL=space-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-client.js","sourceRoot":"","sources":["../src/space-client.ts"],"names":[],"mappings":"AAAA,OA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A;IAC9C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACpC,CAAC;AACH,CAAC","sourcesContent":["import {\n type AccountAgent,\n type Agent,\n type DidString,\n type Infer,\n type InferMethodInputBody,\n type InferMethodOutputBody,\n type LexMap,\n type Main,\n type NsidString,\n type Procedure,\n type Query,\n type RecordKeyOptions,\n type Restricted,\n type XrpcOptions,\n type XrpcResponse,\n isAccountAgent,\n rkeyFor,\n rkeyForCreate,\n xrpc,\n} from '@atproto/lex-client'\nimport type { TypedLexMap } from '@atproto/lex-data'\nimport {\n type RecordKeyValue,\n type RecordSchema,\n type Space,\n getMain,\n} from '@atproto/lex-schema'\nimport { SpaceRef, type SpaceRefString } from '@atproto/syntax'\nimport { delegationTokenProviderFor } from './delegation-token-provider.js'\nimport { main as applyWrites } from './lexicons/com/atproto/space/applyWrites.js'\nimport { main as clearRecords } from './lexicons/com/atproto/space/clearRecords.js'\nimport { main as createRecord } from './lexicons/com/atproto/space/createRecord.js'\nimport { main as createSpace } from './lexicons/com/atproto/space/createSpace.js'\nimport { main as deleteRecord } from './lexicons/com/atproto/space/deleteRecord.js'\nimport type { main as getBlob } from './lexicons/com/atproto/space/getBlob.js'\nimport { main as getRecord } from './lexicons/com/atproto/space/getRecord.js'\nimport type { main as listBlobs } from './lexicons/com/atproto/space/listBlobs.js'\nimport type { main as listRecords } from './lexicons/com/atproto/space/listRecords.js'\nimport { main as putRecord } from './lexicons/com/atproto/space/putRecord.js'\nimport type { SpaceCollectionSchema } from './space-collection.js'\nimport { SpaceReader } from './space-reader.js'\nimport { SpaceWriteOperationHelper } from './write-operation-builder.js'\n\nexport * from './space-reader.js'\nexport type {\n AccountAgent,\n Agent,\n Space,\n SpaceRefString,\n SpaceWriteOperationHelper,\n}\n\nexport declare namespace SpaceClient {\n // From SpaceWriteOperationHelper, for applyWrites()\n export type WriteOperation = SpaceWriteOperationHelper.Operation\n export type WriteOperationsFactory = SpaceWriteOperationHelper.Factory\n\n export type Options = Omit<SpaceReader.Options, 'delegationTokenProvider'>\n\n export type CreateSpaceOptions = Options & {\n signal?: AbortSignal\n }\n\n export type OpenSpaceOptions = Options & {\n agent: Agent\n }\n\n export type CreateSpaceInput<S extends Space> = {\n /** The policy governing the space. */\n policy: InferMethodInputBody<typeof createSpace>['policy']\n } & (S['key'] extends 'nsid'\n ? { skey: NsidString }\n : {\n /**\n * The space key. Defaults to the space type's literal key, or else to a\n * TID generated by the PDS.\n */\n skey?: RecordKeyValue<S['key']>\n })\n\n /**\n * Selects which account's repo, within the space, a read targets. Defaults to\n * the authenticated user's.\n */\n export type RepoOptions = {\n repo?: DidString\n }\n\n export type ListRecordsOptions = Omit<\n SpaceReader.ListRecordsOptions,\n 'repo'\n > &\n RepoOptions\n\n export type GetRecordOptions = Omit<SpaceReader.GetRecordOptions, 'repo'> &\n RepoOptions\n\n export type GetBlobOptions = Omit<SpaceReader.GetBlobOptions, 'repo'> &\n RepoOptions\n\n export type ListBlobsOptions = Omit<SpaceReader.ListBlobsOptions, 'repo'> &\n RepoOptions\n\n export type CreateRecordOptions = Omit<\n XrpcOptions<typeof createRecord>,\n 'body' | 'service' | 'labelers'\n > & {\n /** Tri-state server-side validation, as in `Client.createRecord()`. */\n validate?: boolean\n }\n\n export type PutRecordOptions = Omit<\n XrpcOptions<typeof putRecord>,\n 'body' | 'service' | 'labelers'\n > & {\n /** Tri-state server-side validation, as in `Client.putRecord()`. */\n validate?: boolean\n }\n\n export type DeleteRecordOptions = Omit<\n XrpcOptions<typeof deleteRecord>,\n 'body' | 'service' | 'labelers'\n >\n\n export type ApplyWritesOptions = Omit<\n XrpcOptions<typeof applyWrites>,\n 'body' | 'service' | 'labelers'\n > & {\n /** Tri-state server-side validation, as in `Client.applyWrites()`. */\n validate?: boolean\n }\n\n export type ClearRecordsOptions = Omit<\n XrpcOptions<typeof clearRecords>,\n 'body' | 'service' | 'labelers'\n >\n\n export type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid' | 'any'>\n\n export type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\n\n export type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\n\n export type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\n\n export type ListOptions = Omit<\n ListRecordsOptions,\n 'collection' | 'excludeValues'\n >\n\n export type WriteOutput = InferMethodOutputBody<\n typeof createRecord,\n Uint8Array\n >\n\n export type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof getRecord, Uint8Array>,\n 'value'\n > & { value: Infer<T> }\n\n export type ListOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof listRecords>,\n 'records'\n > & {\n /** Every listed record, flagged with whether it matched the schema. */\n records: ListRecordItem<Infer<T>>[]\n }\n\n export type ListRecordItem<Value extends LexMap> = Omit<\n SpaceReader.ListedRecord,\n 'value'\n > &\n ({ valid: true; value: Value } | { valid: false; value?: LexMap })\n}\n\n/**\n * Reads and writes a space on behalf of a user, through their agent (e.g. their\n * OAuth session).\n *\n * Requests are routed by the repo they target, per the protocol's audience\n * rule:\n * - the user's own repo: their PDS, with their agent. This includes every\n * write, as only the user's own repo can be written to.\n * - another account's repo: that account's PDS, with the space credential\n * presented to that account.\n * - no repo (e.g. `listWriters`): the space host, with the space credential\n * presented to the space authority.\n *\n * The space credential is obtained the first time a request needs one, from a\n * delegation token issued by the user's PDS (which requires a `read` grant on\n * the space), and renewed shortly before it expires. Requests to the user's\n * own repo never need one, so a `read_self` grant is enough for those. Each\n * instance obtains its own credential: keep one instance per space to reuse\n * it.\n *\n * The typed reads and writes (`create()`, `get()`, `list()`, …) only accept\n * the collections declared by the space type, unless `validateRequest` is\n * `false` (with `validateRequest: true`, records are also validated against\n * their schema before being written). The lower level methods\n * (`createRecord()`, …) accept any record.\n *\n * @example\n * ```typescript\n * const space = SpaceClient.openSpace(com.example.forum, spaceUri, {\n * agent: client.agent,\n * })\n *\n * for await (const { $type, repo } of space.writers()) {\n * if ($type !== 'com.atproto.space.defs#repoWrite') continue // removed\n * const { records } = await space.list(com.example.post, { repo })\n * }\n * ```\n */\nexport class SpaceClient<S extends Space = Space> extends SpaceReader<S> {\n /**\n * Opens a space for the user of `agent`. No request is made until the space\n * is used.\n *\n * @throws {TypeError} if `agent` is not authenticated, or if the space is not\n * of the type described by `schema`\n */\n static openSpace<const S extends Space>(\n schema: S,\n space: SpaceRefString | SpaceRef | SpaceReader.AuthorityRef<S>,\n { agent, ...options }: SpaceClient.OpenSpaceOptions,\n ): SpaceClient<S> {\n if (!isAccountAgent(agent)) {\n throw new TypeError('Agent must be authenticated')\n }\n const ref =\n typeof space === 'string'\n ? SpaceRef.parse(space)\n : space instanceof SpaceRef\n ? space\n : schema.spaceRefFor(\n space.authority,\n space.skey as RecordKeyValue<S['key']>,\n )\n return new SpaceClient(agent, schema, ref, options)\n }\n\n /**\n * Creates a space of the type described by `schema`, with the user of\n * `agent` as its authority, and opens it.\n *\n * @throws {XrpcResponseError} with `SpaceAlreadyExists` if the user already\n * has a space of that type and key, or `UnsupportedPolicy` if their PDS does\n * not implement the policy\n *\n * @example\n * ```typescript\n * const space = await SpaceClient.createSpace(client.agent, com.example.forum, {\n * skey: 'general',\n * policy: memberspace.policy.$build({}),\n * })\n * ```\n */\n static async createSpace<const S extends Space>(\n agent: Agent,\n schema: S,\n { policy, skey }: SpaceClient.CreateSpaceInput<S>,\n { signal, ...options }: SpaceClient.CreateSpaceOptions = {},\n ): Promise<SpaceClient<S>> {\n if (!isAccountAgent(agent)) {\n throw new TypeError('Agent must be authenticated')\n }\n // Validates the key, and defaults it for literal keys\n const ref =\n skey != null || schema.key.startsWith('literal:')\n ? schema.spaceRefFor(agent.did, skey as RecordKeyValue<S['key']>)\n : undefined\n const { body } = await xrpc(agent, createSpace, {\n signal,\n body: { spaceType: schema.nsid, skey: ref?.skey, policy },\n })\n return new SpaceClient(agent, schema, SpaceRef.parse(body.space), options)\n }\n\n /**\n * @throws {TypeError} if the space is not of the type described by `schema`\n */\n constructor(\n /** The user's agent (e.g. their OAuth session). */\n readonly agent: AccountAgent,\n schema: S,\n ref: SpaceRef,\n options: SpaceClient.Options = {},\n ) {\n super(schema, ref, {\n ...options,\n delegationTokenProvider: delegationTokenProviderFor(agent),\n })\n }\n\n /** The DID of the authenticated user. */\n get did(): DidString {\n return this.agent.did\n }\n\n /**\n * Makes an XRPC request to the host (PDS) of a repo in the space: with the\n * user's agent for their own repo, and with the space credential otherwise.\n */\n protected override async repoXrpc<const M extends Query | Procedure>(\n repo: DidString,\n ns: Main<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M>> {\n // Override, use the agent directly for the user's own repo.\n if (repo === this.did) {\n return xrpc(this.agent, ns, options)\n }\n\n return super.repoXrpc(repo, ns, options)\n }\n\n override async listRecords({\n repo = this.did,\n ...options\n }: SpaceClient.ListRecordsOptions = {}): Promise<\n XrpcResponse<typeof listRecords>\n > {\n return super.listRecords({ ...options, repo })\n }\n\n override records({\n repo = this.did,\n ...options\n }: SpaceClient.ListRecordsOptions = {}): AsyncGenerator<\n SpaceReader.ListedRecord,\n void,\n undefined\n > {\n return super.records({ ...options, repo })\n }\n\n /**\n * Gets a record. When read from another account's repo, the record is\n * verified against the MAC its host computed for this request.\n *\n * @throws {SpaceRepoVerificationError} if the record fails verification\n */\n override async getRecord(\n collection: NsidString,\n rkey: string,\n { repo = this.did, ...options }: SpaceClient.GetRecordOptions = {},\n ): Promise<XrpcResponse<typeof getRecord>> {\n if (repo === this.did) {\n return xrpc(this.agent, getRecord, {\n ...options,\n service: null,\n labelers: null,\n params: { space: this.uri, repo, collection, rkey },\n })\n }\n\n return super.getRecord(collection, rkey, { ...options, repo })\n }\n\n override async getBlob({\n repo = this.did,\n ...options\n }: SpaceClient.GetBlobOptions): Promise<XrpcResponse<typeof getBlob>> {\n return super.getBlob({ ...options, repo })\n }\n\n override async listBlobs({\n repo = this.did,\n ...options\n }: SpaceClient.ListBlobsOptions = {}): Promise<\n XrpcResponse<typeof listBlobs>\n > {\n return super.listBlobs({ ...options, repo })\n }\n\n async createRecord(\n record: TypedLexMap<NsidString>,\n rkey?: string,\n { validate, ...options }: SpaceClient.CreateRecordOptions = {},\n ): Promise<XrpcResponse<typeof createRecord>> {\n return xrpc(this.agent, createRecord, {\n ...options,\n service: null,\n labelers: null,\n body: {\n space: this.uri,\n repo: this.did,\n collection: record.$type,\n rkey,\n validate,\n record,\n },\n })\n }\n\n async putRecord(\n record: TypedLexMap<NsidString>,\n rkey: string,\n { validate, ...options }: SpaceClient.PutRecordOptions = {},\n ): Promise<XrpcResponse<typeof putRecord>> {\n return xrpc(this.agent, putRecord, {\n ...options,\n service: null,\n labelers: null,\n body: {\n space: this.uri,\n repo: this.did,\n collection: record.$type,\n rkey,\n validate,\n record,\n },\n })\n }\n\n async deleteRecord(\n collection: NsidString,\n rkey: string,\n options: SpaceClient.DeleteRecordOptions = {},\n ): Promise<XrpcResponse<typeof deleteRecord>> {\n return xrpc(this.agent, deleteRecord, {\n ...options,\n service: null,\n labelers: null,\n body: { space: this.uri, repo: this.did, collection, rkey },\n })\n }\n\n /**\n * Applies a batch of writes to the user's repo in the space, atomically.\n *\n * @example\n * ```typescript\n * await space.applyWrites((op) => [\n * op.create(com.example.post, { text: 'Hello' }),\n * op.delete(com.example.post, { rkey: '3jxf7z2k3q2' }),\n * ])\n * ```\n */\n async applyWrites(\n factory: SpaceClient.WriteOperationsFactory,\n { validate, ...options }: SpaceClient.ApplyWritesOptions = {},\n ): Promise<XrpcResponse<typeof applyWrites>> {\n return xrpc(this.agent, applyWrites, {\n ...options,\n service: null,\n labelers: null,\n body: {\n space: this.uri,\n repo: this.did,\n validate,\n writes: SpaceWriteOperationHelper.build(factory),\n },\n })\n }\n\n /** Deletes every record in the user's repo in the space. */\n async clearRecords(\n options: SpaceClient.ClearRecordsOptions = {},\n ): Promise<XrpcResponse<typeof clearRecords>> {\n return xrpc(this.agent, clearRecords, {\n ...options,\n service: null,\n labelers: null,\n body: { space: this.uri, repo: this.did },\n })\n }\n\n /**\n * Creates a record in the user's repo in the space, as `Client.create()`\n * does in their public repo.\n */\n async create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends SpaceClient.CreateOptions<T>\n ? SpaceCollectionSchema<S, T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<SpaceClient.WriteOutput>\n async create<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.CreateOptions<T>,\n ): Promise<SpaceClient.WriteOutput>\n async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.CreateOptions<T> & { validateRequest: false },\n ): Promise<SpaceClient.WriteOutput>\n async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.CreateOptions<T> = {} as SpaceClient.CreateOptions<T>,\n ): Promise<SpaceClient.WriteOutput> {\n const schema: T = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n const record = schema.build(input) as TypedLexMap<NsidString>\n if (options.validateRequest) schema.validate(record)\n const rkey = rkeyForCreate(schema, options.rkey)\n if (rkey !== undefined) schema.keySchema.assert(rkey)\n const response = await this.createRecord(record, rkey, options)\n return response.body\n }\n\n /**\n * Creates or updates a record in the user's repo in the space, as\n * `Client.put()` does in their public repo.\n */\n async put<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends SpaceClient.PutOptions<T>\n ? SpaceCollectionSchema<S, T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<SpaceClient.WriteOutput>\n async put<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.PutOptions<T>,\n ): Promise<SpaceClient.WriteOutput>\n async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.PutOptions<T> & { validateRequest: false },\n ): Promise<SpaceClient.WriteOutput>\n async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: SpaceClient.PutOptions<T> = {} as SpaceClient.PutOptions<T>,\n ): Promise<SpaceClient.WriteOutput> {\n const schema: T = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n const record = schema.build(input) as TypedLexMap<NsidString>\n if (options.validateRequest) schema.validate(record)\n const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey))\n const response = await this.putRecord(record, rkey, options)\n return response.body\n }\n\n /** Deletes a record from the user's repo in the space. */\n async delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends SpaceClient.DeleteOptions<T>\n ? SpaceCollectionSchema<S, T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<void>\n async delete<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n options: SpaceClient.DeleteOptions<T>,\n ): Promise<void>\n async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.DeleteOptions<T> & { validateRequest: false },\n ): Promise<void>\n async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.DeleteOptions<T> = {} as SpaceClient.DeleteOptions<T>,\n ): Promise<void> {\n const schema = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey))\n await this.deleteRecord(schema.$type, rkey, options)\n }\n\n /**\n * Gets a record, validated against its schema. Reads the user's own repo\n * unless `options.repo` is set.\n */\n async get<const T extends RecordSchema>(\n ns: T['key'] extends `literal:${string}`\n ? SpaceCollectionSchema<S, T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<SpaceClient.GetOutput<T>>\n async get<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n options: SpaceClient.GetOptions<T>,\n ): Promise<SpaceClient.GetOutput<T>>\n async get<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.GetOptions<T> & { validateRequest: false },\n ): Promise<SpaceClient.GetOutput<T>>\n async get<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.GetOptions<T> = {} as SpaceClient.GetOptions<T>,\n ): Promise<SpaceClient.GetOutput<T>> {\n const schema = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n const rkey = schema.keySchema.parse(rkeyFor(schema, options.rkey))\n const response = await this.getRecord(schema.$type, rkey, options)\n const value = schema.validate(response.body.value)\n return { ...response.body, value }\n }\n\n /**\n * Lists a collection's records, each validated against its schema. Lists\n * the user's own repo unless `options.repo` is set.\n *\n * @example\n * ```typescript\n * const { records, cursor } = await space.list(com.example.post, { repo })\n * for (const record of records) {\n * if (record.valid) record.value // com.example.post.Main\n * }\n * ```\n */\n async list<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n options?: SpaceClient.ListOptions,\n ): Promise<SpaceClient.ListOutput<T>>\n async list<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.ListOptions & { validateRequest: false },\n ): Promise<SpaceClient.ListOutput<T>>\n async list<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.ListOptions = {},\n ): Promise<SpaceClient.ListOutput<T>> {\n const schema = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n const { body } = await this.listRecords({\n ...options,\n collection: schema.$type,\n })\n const records = body.records.map(processListRecord, schema)\n return { ...body, records }\n }\n\n /**\n * Iterates over a collection's records, each validated against its schema,\n * handling pagination. Lists the user's own repo unless `options.repo` is\n * set.\n */\n listAll<const T extends RecordSchema>(\n ns: SpaceCollectionSchema<S, T>,\n options?: SpaceClient.ListOptions,\n ): AsyncGenerator<SpaceClient.ListRecordItem<Infer<T>>, void, undefined>\n listAll<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.ListOptions & { validateRequest: false },\n ): AsyncGenerator<SpaceClient.ListRecordItem<Infer<T>>, void, undefined>\n async *listAll<const T extends RecordSchema>(\n ns: Main<T>,\n options: SpaceClient.ListOptions = {},\n ): AsyncGenerator<SpaceClient.ListRecordItem<Infer<T>>, void, undefined> {\n const schema = getMain(ns)\n if (options.validateRequest !== false) this.assertCollection(schema.$type)\n for await (const record of this.records({\n ...options,\n collection: schema.$type,\n })) {\n yield processListRecord.call(schema, record)\n }\n }\n}\n\nfunction processListRecord<T extends RecordSchema>(\n this: T,\n record: SpaceReader.ListedRecord,\n): SpaceClient.ListRecordItem<Infer<T>> {\n const result = this.safeValidate(record.value)\n if (result.success) {\n return { ...record, valid: true, value: result.value }\n } else {\n return { ...record, valid: false }\n }\n}\n"]}