the statusphere demo reworked into a vite/react app in a monorepo
at main 286 lines 7.8 kB view raw
1/** 2 * GENERATED CODE - DO NOT MODIFY 3 */ 4import { 5 AuthVerifier, 6 createServer as createXrpcServer, 7 StreamAuthVerifier, 8 Options as XrpcOptions, 9 Server as XrpcServer, 10} from '@atproto/xrpc-server' 11 12import { schemas } from './lexicons.js' 13import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites.js' 14import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js' 15import * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord.js' 16import * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo.js' 17import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord.js' 18import * as ComAtprotoRepoImportRepo from './types/com/atproto/repo/importRepo.js' 19import * as ComAtprotoRepoListMissingBlobs from './types/com/atproto/repo/listMissingBlobs.js' 20import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords.js' 21import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord.js' 22import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob.js' 23import * as XyzStatusphereGetStatuses from './types/xyz/statusphere/getStatuses.js' 24import * as XyzStatusphereGetUser from './types/xyz/statusphere/getUser.js' 25import * as XyzStatusphereSendStatus from './types/xyz/statusphere/sendStatus.js' 26 27export function createServer(options?: XrpcOptions): Server { 28 return new Server(options) 29} 30 31export class Server { 32 xrpc: XrpcServer 33 xyz: XyzNS 34 com: ComNS 35 app: AppNS 36 37 constructor(options?: XrpcOptions) { 38 this.xrpc = createXrpcServer(schemas, options) 39 this.xyz = new XyzNS(this) 40 this.com = new ComNS(this) 41 this.app = new AppNS(this) 42 } 43} 44 45export class XyzNS { 46 _server: Server 47 statusphere: XyzStatusphereNS 48 49 constructor(server: Server) { 50 this._server = server 51 this.statusphere = new XyzStatusphereNS(server) 52 } 53} 54 55export class XyzStatusphereNS { 56 _server: Server 57 58 constructor(server: Server) { 59 this._server = server 60 } 61 62 getStatuses<AV extends AuthVerifier>( 63 cfg: ConfigOf< 64 AV, 65 XyzStatusphereGetStatuses.Handler<ExtractAuth<AV>>, 66 XyzStatusphereGetStatuses.HandlerReqCtx<ExtractAuth<AV>> 67 >, 68 ) { 69 const nsid = 'xyz.statusphere.getStatuses' // @ts-ignore 70 return this._server.xrpc.method(nsid, cfg) 71 } 72 73 getUser<AV extends AuthVerifier>( 74 cfg: ConfigOf< 75 AV, 76 XyzStatusphereGetUser.Handler<ExtractAuth<AV>>, 77 XyzStatusphereGetUser.HandlerReqCtx<ExtractAuth<AV>> 78 >, 79 ) { 80 const nsid = 'xyz.statusphere.getUser' // @ts-ignore 81 return this._server.xrpc.method(nsid, cfg) 82 } 83 84 sendStatus<AV extends AuthVerifier>( 85 cfg: ConfigOf< 86 AV, 87 XyzStatusphereSendStatus.Handler<ExtractAuth<AV>>, 88 XyzStatusphereSendStatus.HandlerReqCtx<ExtractAuth<AV>> 89 >, 90 ) { 91 const nsid = 'xyz.statusphere.sendStatus' // @ts-ignore 92 return this._server.xrpc.method(nsid, cfg) 93 } 94} 95 96export class ComNS { 97 _server: Server 98 atproto: ComAtprotoNS 99 100 constructor(server: Server) { 101 this._server = server 102 this.atproto = new ComAtprotoNS(server) 103 } 104} 105 106export class ComAtprotoNS { 107 _server: Server 108 repo: ComAtprotoRepoNS 109 110 constructor(server: Server) { 111 this._server = server 112 this.repo = new ComAtprotoRepoNS(server) 113 } 114} 115 116export class ComAtprotoRepoNS { 117 _server: Server 118 119 constructor(server: Server) { 120 this._server = server 121 } 122 123 applyWrites<AV extends AuthVerifier>( 124 cfg: ConfigOf< 125 AV, 126 ComAtprotoRepoApplyWrites.Handler<ExtractAuth<AV>>, 127 ComAtprotoRepoApplyWrites.HandlerReqCtx<ExtractAuth<AV>> 128 >, 129 ) { 130 const nsid = 'com.atproto.repo.applyWrites' // @ts-ignore 131 return this._server.xrpc.method(nsid, cfg) 132 } 133 134 createRecord<AV extends AuthVerifier>( 135 cfg: ConfigOf< 136 AV, 137 ComAtprotoRepoCreateRecord.Handler<ExtractAuth<AV>>, 138 ComAtprotoRepoCreateRecord.HandlerReqCtx<ExtractAuth<AV>> 139 >, 140 ) { 141 const nsid = 'com.atproto.repo.createRecord' // @ts-ignore 142 return this._server.xrpc.method(nsid, cfg) 143 } 144 145 deleteRecord<AV extends AuthVerifier>( 146 cfg: ConfigOf< 147 AV, 148 ComAtprotoRepoDeleteRecord.Handler<ExtractAuth<AV>>, 149 ComAtprotoRepoDeleteRecord.HandlerReqCtx<ExtractAuth<AV>> 150 >, 151 ) { 152 const nsid = 'com.atproto.repo.deleteRecord' // @ts-ignore 153 return this._server.xrpc.method(nsid, cfg) 154 } 155 156 describeRepo<AV extends AuthVerifier>( 157 cfg: ConfigOf< 158 AV, 159 ComAtprotoRepoDescribeRepo.Handler<ExtractAuth<AV>>, 160 ComAtprotoRepoDescribeRepo.HandlerReqCtx<ExtractAuth<AV>> 161 >, 162 ) { 163 const nsid = 'com.atproto.repo.describeRepo' // @ts-ignore 164 return this._server.xrpc.method(nsid, cfg) 165 } 166 167 getRecord<AV extends AuthVerifier>( 168 cfg: ConfigOf< 169 AV, 170 ComAtprotoRepoGetRecord.Handler<ExtractAuth<AV>>, 171 ComAtprotoRepoGetRecord.HandlerReqCtx<ExtractAuth<AV>> 172 >, 173 ) { 174 const nsid = 'com.atproto.repo.getRecord' // @ts-ignore 175 return this._server.xrpc.method(nsid, cfg) 176 } 177 178 importRepo<AV extends AuthVerifier>( 179 cfg: ConfigOf< 180 AV, 181 ComAtprotoRepoImportRepo.Handler<ExtractAuth<AV>>, 182 ComAtprotoRepoImportRepo.HandlerReqCtx<ExtractAuth<AV>> 183 >, 184 ) { 185 const nsid = 'com.atproto.repo.importRepo' // @ts-ignore 186 return this._server.xrpc.method(nsid, cfg) 187 } 188 189 listMissingBlobs<AV extends AuthVerifier>( 190 cfg: ConfigOf< 191 AV, 192 ComAtprotoRepoListMissingBlobs.Handler<ExtractAuth<AV>>, 193 ComAtprotoRepoListMissingBlobs.HandlerReqCtx<ExtractAuth<AV>> 194 >, 195 ) { 196 const nsid = 'com.atproto.repo.listMissingBlobs' // @ts-ignore 197 return this._server.xrpc.method(nsid, cfg) 198 } 199 200 listRecords<AV extends AuthVerifier>( 201 cfg: ConfigOf< 202 AV, 203 ComAtprotoRepoListRecords.Handler<ExtractAuth<AV>>, 204 ComAtprotoRepoListRecords.HandlerReqCtx<ExtractAuth<AV>> 205 >, 206 ) { 207 const nsid = 'com.atproto.repo.listRecords' // @ts-ignore 208 return this._server.xrpc.method(nsid, cfg) 209 } 210 211 putRecord<AV extends AuthVerifier>( 212 cfg: ConfigOf< 213 AV, 214 ComAtprotoRepoPutRecord.Handler<ExtractAuth<AV>>, 215 ComAtprotoRepoPutRecord.HandlerReqCtx<ExtractAuth<AV>> 216 >, 217 ) { 218 const nsid = 'com.atproto.repo.putRecord' // @ts-ignore 219 return this._server.xrpc.method(nsid, cfg) 220 } 221 222 uploadBlob<AV extends AuthVerifier>( 223 cfg: ConfigOf< 224 AV, 225 ComAtprotoRepoUploadBlob.Handler<ExtractAuth<AV>>, 226 ComAtprotoRepoUploadBlob.HandlerReqCtx<ExtractAuth<AV>> 227 >, 228 ) { 229 const nsid = 'com.atproto.repo.uploadBlob' // @ts-ignore 230 return this._server.xrpc.method(nsid, cfg) 231 } 232} 233 234export class AppNS { 235 _server: Server 236 bsky: AppBskyNS 237 238 constructor(server: Server) { 239 this._server = server 240 this.bsky = new AppBskyNS(server) 241 } 242} 243 244export class AppBskyNS { 245 _server: Server 246 actor: AppBskyActorNS 247 248 constructor(server: Server) { 249 this._server = server 250 this.actor = new AppBskyActorNS(server) 251 } 252} 253 254export class AppBskyActorNS { 255 _server: Server 256 257 constructor(server: Server) { 258 this._server = server 259 } 260} 261 262type SharedRateLimitOpts<T> = { 263 name: string 264 calcKey?: (ctx: T) => string | null 265 calcPoints?: (ctx: T) => number 266} 267type RouteRateLimitOpts<T> = { 268 durationMs: number 269 points: number 270 calcKey?: (ctx: T) => string | null 271 calcPoints?: (ctx: T) => number 272} 273type HandlerOpts = { blobLimit?: number } 274type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T> 275type ConfigOf<Auth, Handler, ReqCtx> = 276 | Handler 277 | { 278 auth?: Auth 279 opts?: HandlerOpts 280 rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[] 281 handler: Handler 282 } 283type ExtractAuth<AV extends AuthVerifier | StreamAuthVerifier> = Extract< 284 Awaited<ReturnType<AV>>, 285 { credentials: unknown } 286>