grain.social is a photo sharing platform built on atproto.
at gallery-sort 211 lines 4.8 kB view raw
1/** 2 * GENERATED CODE - DO NOT MODIFY 3 */ 4import { 5 createServer as createXrpcServer, 6 Server as XrpcServer, 7 type Options as XrpcOptions, 8 type AuthVerifier, 9 type StreamAuthVerifier, 10} from "npm:@atproto/xrpc-server" 11import { schemas } from './lexicons.ts' 12 13export const APP_BSKY_GRAPH = { 14 DefsModlist: 'app.bsky.graph.defs#modlist', 15 DefsCuratelist: 'app.bsky.graph.defs#curatelist', 16 DefsReferencelist: 'app.bsky.graph.defs#referencelist', 17} 18export const APP_BSKY_FEED = { 19 DefsRequestLess: 'app.bsky.feed.defs#requestLess', 20 DefsRequestMore: 'app.bsky.feed.defs#requestMore', 21 DefsInteractionLike: 'app.bsky.feed.defs#interactionLike', 22 DefsInteractionSeen: 'app.bsky.feed.defs#interactionSeen', 23 DefsClickthroughItem: 'app.bsky.feed.defs#clickthroughItem', 24 DefsContentModeVideo: 'app.bsky.feed.defs#contentModeVideo', 25 DefsInteractionQuote: 'app.bsky.feed.defs#interactionQuote', 26 DefsInteractionReply: 'app.bsky.feed.defs#interactionReply', 27 DefsInteractionShare: 'app.bsky.feed.defs#interactionShare', 28 DefsClickthroughEmbed: 'app.bsky.feed.defs#clickthroughEmbed', 29 DefsInteractionRepost: 'app.bsky.feed.defs#interactionRepost', 30 DefsClickthroughAuthor: 'app.bsky.feed.defs#clickthroughAuthor', 31 DefsClickthroughReposter: 'app.bsky.feed.defs#clickthroughReposter', 32 DefsContentModeUnspecified: 'app.bsky.feed.defs#contentModeUnspecified', 33} 34 35export function createServer(options?: XrpcOptions): Server { 36 return new Server(options) 37} 38 39export class Server { 40 xrpc: XrpcServer 41 app: AppNS 42 social: SocialNS 43 com: ComNS 44 45 constructor(options?: XrpcOptions) { 46 this.xrpc = createXrpcServer(schemas, options) 47 this.app = new AppNS(this) 48 this.social = new SocialNS(this) 49 this.com = new ComNS(this) 50 } 51} 52 53export class AppNS { 54 _server: Server 55 bsky: AppBskyNS 56 57 constructor(server: Server) { 58 this._server = server 59 this.bsky = new AppBskyNS(server) 60 } 61} 62 63export class AppBskyNS { 64 _server: Server 65 embed: AppBskyEmbedNS 66 graph: AppBskyGraphNS 67 feed: AppBskyFeedNS 68 richtext: AppBskyRichtextNS 69 actor: AppBskyActorNS 70 71 constructor(server: Server) { 72 this._server = server 73 this.embed = new AppBskyEmbedNS(server) 74 this.graph = new AppBskyGraphNS(server) 75 this.feed = new AppBskyFeedNS(server) 76 this.richtext = new AppBskyRichtextNS(server) 77 this.actor = new AppBskyActorNS(server) 78 } 79} 80 81export class AppBskyEmbedNS { 82 _server: Server 83 84 constructor(server: Server) { 85 this._server = server 86 } 87} 88 89export class AppBskyGraphNS { 90 _server: Server 91 92 constructor(server: Server) { 93 this._server = server 94 } 95} 96 97export class AppBskyFeedNS { 98 _server: Server 99 100 constructor(server: Server) { 101 this._server = server 102 } 103} 104 105export class AppBskyRichtextNS { 106 _server: Server 107 108 constructor(server: Server) { 109 this._server = server 110 } 111} 112 113export class AppBskyActorNS { 114 _server: Server 115 116 constructor(server: Server) { 117 this._server = server 118 } 119} 120 121export class SocialNS { 122 _server: Server 123 grain: SocialGrainNS 124 125 constructor(server: Server) { 126 this._server = server 127 this.grain = new SocialGrainNS(server) 128 } 129} 130 131export class SocialGrainNS { 132 _server: Server 133 gallery: SocialGrainGalleryNS 134 actor: SocialGrainActorNS 135 136 constructor(server: Server) { 137 this._server = server 138 this.gallery = new SocialGrainGalleryNS(server) 139 this.actor = new SocialGrainActorNS(server) 140 } 141} 142 143export class SocialGrainGalleryNS { 144 _server: Server 145 146 constructor(server: Server) { 147 this._server = server 148 } 149} 150 151export class SocialGrainActorNS { 152 _server: Server 153 154 constructor(server: Server) { 155 this._server = server 156 } 157} 158 159export class ComNS { 160 _server: Server 161 atproto: ComAtprotoNS 162 163 constructor(server: Server) { 164 this._server = server 165 this.atproto = new ComAtprotoNS(server) 166 } 167} 168 169export class ComAtprotoNS { 170 _server: Server 171 repo: ComAtprotoRepoNS 172 173 constructor(server: Server) { 174 this._server = server 175 this.repo = new ComAtprotoRepoNS(server) 176 } 177} 178 179export class ComAtprotoRepoNS { 180 _server: Server 181 182 constructor(server: Server) { 183 this._server = server 184 } 185} 186 187type SharedRateLimitOpts<T> = { 188 name: string 189 calcKey?: (ctx: T) => string | null 190 calcPoints?: (ctx: T) => number 191} 192type RouteRateLimitOpts<T> = { 193 durationMs: number 194 points: number 195 calcKey?: (ctx: T) => string | null 196 calcPoints?: (ctx: T) => number 197} 198type HandlerOpts = { blobLimit?: number } 199type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T> 200type ConfigOf<Auth, Handler, ReqCtx> = 201 | Handler 202 | { 203 auth?: Auth 204 opts?: HandlerOpts 205 rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[] 206 handler: Handler 207 } 208type ExtractAuth<AV extends AuthVerifier | StreamAuthVerifier> = Extract< 209 Awaited<ReturnType<AV>>, 210 { credentials: unknown } 211>