├── .prettierrc ├── src ├── db │ ├── schema.ts │ ├── index.ts │ └── migrations.ts ├── lexicon │ ├── util.ts │ └── types │ │ ├── app │ │ └── bsky │ │ │ ├── graph │ │ │ ├── block.ts │ │ │ ├── follow.ts │ │ │ ├── listblock.ts │ │ │ ├── listitem.ts │ │ │ ├── muteActor.ts │ │ │ ├── unmuteActor.ts │ │ │ ├── muteActorList.ts │ │ │ ├── unmuteActorList.ts │ │ │ ├── list.ts │ │ │ ├── getSuggestedFollowsByActor.ts │ │ │ ├── getListMutes.ts │ │ │ ├── getListBlocks.ts │ │ │ ├── getBlocks.ts │ │ │ ├── getMutes.ts │ │ │ ├── getLists.ts │ │ │ ├── getList.ts │ │ │ ├── getFollowers.ts │ │ │ ├── getFollows.ts │ │ │ └── defs.ts │ │ │ ├── feed │ │ │ ├── like.ts │ │ │ ├── repost.ts │ │ │ ├── generator.ts │ │ │ ├── getPosts.ts │ │ │ ├── getFeedGenerators.ts │ │ │ ├── getFeedGenerator.ts │ │ │ ├── getSuggestedFeeds.ts │ │ │ ├── getActorFeeds.ts │ │ │ ├── getTimeline.ts │ │ │ ├── getFeed.ts │ │ │ ├── getListFeed.ts │ │ │ ├── getFeedSkeleton.ts │ │ │ ├── getActorLikes.ts │ │ │ ├── getRepostedBy.ts │ │ │ ├── getPostThread.ts │ │ │ ├── getAuthorFeed.ts │ │ │ ├── searchPosts.ts │ │ │ ├── getLikes.ts │ │ │ ├── describeFeedGenerator.ts │ │ │ ├── threadgate.ts │ │ │ └── post.ts │ │ │ ├── actor │ │ │ ├── profile.ts │ │ │ ├── putPreferences.ts │ │ │ ├── getProfile.ts │ │ │ ├── getPreferences.ts │ │ │ ├── getProfiles.ts │ │ │ ├── getSuggestions.ts │ │ │ ├── searchActorsTypeahead.ts │ │ │ └── searchActors.ts │ │ │ ├── notification │ │ │ ├── updateSeen.ts │ │ │ ├── registerPush.ts │ │ │ ├── getUnreadCount.ts │ │ │ └── listNotifications.ts │ │ │ ├── unspecced │ │ │ ├── defs.ts │ │ │ ├── getPopular.ts │ │ │ ├── getPopularFeedGenerators.ts │ │ │ ├── getTimelineSkeleton.ts │ │ │ ├── searchPostsSkeleton.ts │ │ │ └── searchActorsSkeleton.ts │ │ │ ├── embed │ │ │ ├── recordWithMedia.ts │ │ │ ├── external.ts │ │ │ ├── images.ts │ │ │ └── record.ts │ │ │ └── richtext │ │ │ └── facet.ts │ │ └── com │ │ └── atproto │ │ ├── repo │ │ ├── strongRef.ts │ │ ├── uploadBlob.ts │ │ ├── describeRepo.ts │ │ ├── deleteRecord.ts │ │ ├── getRecord.ts │ │ ├── createRecord.ts │ │ ├── putRecord.ts │ │ ├── listRecords.ts │ │ └── applyWrites.ts │ │ ├── server │ │ ├── deleteSession.ts │ │ ├── requestAccountDelete.ts │ │ ├── revokeAppPassword.ts │ │ ├── requestPasswordReset.ts │ │ ├── resetPassword.ts │ │ ├── deleteAccount.ts │ │ ├── getSession.ts │ │ ├── refreshSession.ts │ │ ├── defs.ts │ │ ├── createInviteCode.ts │ │ ├── getAccountInviteCodes.ts │ │ ├── createSession.ts │ │ ├── createAccount.ts │ │ ├── listAppPasswords.ts │ │ ├── describeServer.ts │ │ ├── createAppPassword.ts │ │ └── createInviteCodes.ts │ │ ├── identity │ │ ├── updateHandle.ts │ │ └── resolveHandle.ts │ │ ├── admin │ │ ├── updateAccountHandle.ts │ │ ├── disableInviteCodes.ts │ │ ├── updateAccountEmail.ts │ │ ├── disableAccountInvites.ts │ │ ├── enableAccountInvites.ts │ │ ├── getModerationAction.ts │ │ ├── getModerationReport.ts │ │ ├── getRepo.ts │ │ ├── getRecord.ts │ │ ├── sendEmail.ts │ │ ├── getModerationActions.ts │ │ ├── reverseModerationAction.ts │ │ ├── resolveModerationReports.ts │ │ ├── getInviteCodes.ts │ │ ├── searchRepos.ts │ │ ├── getModerationReports.ts │ │ └── takeModerationAction.ts │ │ ├── sync │ │ ├── notifyOfUpdate.ts │ │ ├── requestCrawl.ts │ │ ├── getCheckout.ts │ │ ├── getBlocks.ts │ │ ├── getBlob.ts │ │ ├── getHead.ts │ │ ├── getRepo.ts │ │ ├── getLatestCommit.ts │ │ ├── getRecord.ts │ │ ├── listBlobs.ts │ │ └── listRepos.ts │ │ ├── moderation │ │ ├── defs.ts │ │ └── createReport.ts │ │ └── label │ │ ├── queryLabels.ts │ │ ├── subscribeLabels.ts │ │ └── defs.ts ├── algos │ ├── index.ts │ └── whats-alf.ts ├── config.ts ├── methods │ ├── describe-generator.ts │ └── feed-generation.ts ├── well-known.ts ├── auth.ts ├── index.ts ├── subscription.ts └── server.ts ├── tsconfig.json ├── .env.example ├── LICENSE ├── package.json ├── scripts ├── unpublishFeedGen.ts └── publishFeedGen.ts └── .gitignore /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "tabWidth": 2, 4 | "semi": false, 5 | "singleQuote": true, 6 | "overrides": [ 7 | { 8 | "files": "*.hbs", 9 | "options": { 10 | "singleQuote": false 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/db/schema.ts: -------------------------------------------------------------------------------- 1 | export type DatabaseSchema = { 2 | post: Post 3 | sub_state: SubState 4 | } 5 | 6 | export type Post = { 7 | uri: string 8 | cid: string 9 | indexedAt: string 10 | } 11 | 12 | export type SubState = { 13 | service: string 14 | cursor: number 15 | } 16 | -------------------------------------------------------------------------------- /src/lexicon/util.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | export function isObj(v: unknown): v is Record { 5 | return typeof v === 'object' && v !== null 6 | } 7 | 8 | export function hasProp( 9 | data: object, 10 | prop: K, 11 | ): data is Record { 12 | return prop in data 13 | } 14 | -------------------------------------------------------------------------------- /src/algos/index.ts: -------------------------------------------------------------------------------- 1 | import { AppContext } from '../config' 2 | import { 3 | QueryParams, 4 | OutputSchema as AlgoOutput, 5 | } from '../lexicon/types/app/bsky/feed/getFeedSkeleton' 6 | import * as whatsAlf from './whats-alf' 7 | 8 | type AlgoHandler = (ctx: AppContext, params: QueryParams) => Promise 9 | 10 | const algos: Record = { 11 | [whatsAlf.shortname]: whatsAlf.handler, 12 | } 13 | 14 | export default algos 15 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { Database } from './db' 2 | import { DidResolver } from '@atproto/identity' 3 | 4 | export type AppContext = { 5 | db: Database 6 | didResolver: DidResolver 7 | cfg: Config 8 | } 9 | 10 | export type Config = { 11 | port: number 12 | listenhost: string 13 | hostname: string 14 | sqliteLocation: string 15 | subscriptionEndpoint: string 16 | serviceDid: string 17 | publisherDid: string 18 | subscriptionReconnectDelay: number 19 | } 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | "lib": [ 5 | "ESNext", 6 | ], 7 | "outDir": "dist", 8 | "module": "CommonJS", 9 | "target": "ES6", 10 | "esModuleInterop": true, 11 | "moduleResolution": "node", 12 | "alwaysStrict": true, 13 | "allowUnreachableCode": false, 14 | "strictNullChecks": true, 15 | "skipLibCheck": true 16 | }, 17 | "include": ["./src/**/*.ts"], 18 | "exclude": [ 19 | "node_modules" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/db/index.ts: -------------------------------------------------------------------------------- 1 | import SqliteDb from 'better-sqlite3' 2 | import { Kysely, Migrator, SqliteDialect } from 'kysely' 3 | import { DatabaseSchema } from './schema' 4 | import { migrationProvider } from './migrations' 5 | 6 | export const createDb = (location: string): Database => { 7 | return new Kysely({ 8 | dialect: new SqliteDialect({ 9 | database: new SqliteDb(location), 10 | }), 11 | }) 12 | } 13 | 14 | export const migrateToLatest = async (db: Database) => { 15 | const migrator = new Migrator({ db, provider: migrationProvider }) 16 | const { error } = await migrator.migrateToLatest() 17 | if (error) throw error 18 | } 19 | 20 | export type Database = Kysely 21 | -------------------------------------------------------------------------------- /src/methods/describe-generator.ts: -------------------------------------------------------------------------------- 1 | import { Server } from '../lexicon' 2 | import { AppContext } from '../config' 3 | import algos from '../algos' 4 | import { AtUri } from '@atproto/syntax' 5 | 6 | export default function (server: Server, ctx: AppContext) { 7 | server.app.bsky.feed.describeFeedGenerator(async () => { 8 | const feeds = Object.keys(algos).map((shortname) => ({ 9 | uri: AtUri.make( 10 | ctx.cfg.publisherDid, 11 | 'app.bsky.feed.generator', 12 | shortname, 13 | ).toString(), 14 | })) 15 | return { 16 | encoding: 'application/json', 17 | body: { 18 | did: ctx.cfg.serviceDid, 19 | feeds, 20 | }, 21 | } 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /src/well-known.ts: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import { AppContext } from './config' 3 | 4 | const makeRouter = (ctx: AppContext) => { 5 | const router = express.Router() 6 | 7 | router.get('/.well-known/did.json', (_req, res) => { 8 | if (!ctx.cfg.serviceDid.endsWith(ctx.cfg.hostname)) { 9 | return res.sendStatus(404) 10 | } 11 | res.json({ 12 | '@context': ['https://www.w3.org/ns/did/v1'], 13 | id: ctx.cfg.serviceDid, 14 | service: [ 15 | { 16 | id: '#bsky_fg', 17 | type: 'BskyFeedGenerator', 18 | serviceEndpoint: `https://${ctx.cfg.hostname}`, 19 | }, 20 | ], 21 | }) 22 | }) 23 | 24 | return router 25 | } 26 | export default makeRouter 27 | -------------------------------------------------------------------------------- /src/auth.ts: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import { verifyJwt, AuthRequiredError, parseReqNsid } from '@atproto/xrpc-server' 3 | import { DidResolver } from '@atproto/identity' 4 | 5 | export const validateAuth = async ( 6 | req: express.Request, 7 | serviceDid: string, 8 | didResolver: DidResolver, 9 | ): Promise => { 10 | const { authorization = '' } = req.headers 11 | if (!authorization.startsWith('Bearer ')) { 12 | throw new AuthRequiredError() 13 | } 14 | const jwt = authorization.replace('Bearer ', '').trim() 15 | const nsid = parseReqNsid(req) 16 | const parsed = await verifyJwt(jwt, serviceDid, nsid, async (did: string) => { 17 | return didResolver.resolveAtprotoKey(did) 18 | }) 19 | return parsed.iss 20 | } 21 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/block.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Record { 10 | subject: string 11 | createdAt: string 12 | [k: string]: unknown 13 | } 14 | 15 | export function isRecord(v: unknown): v is Record { 16 | return ( 17 | isObj(v) && 18 | hasProp(v, '$type') && 19 | (v.$type === 'app.bsky.graph.block#main' || 20 | v.$type === 'app.bsky.graph.block') 21 | ) 22 | } 23 | 24 | export function validateRecord(v: unknown): ValidationResult { 25 | return lexicons.validate('app.bsky.graph.block#main', v) 26 | } 27 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/follow.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Record { 10 | subject: string 11 | createdAt: string 12 | [k: string]: unknown 13 | } 14 | 15 | export function isRecord(v: unknown): v is Record { 16 | return ( 17 | isObj(v) && 18 | hasProp(v, '$type') && 19 | (v.$type === 'app.bsky.graph.follow#main' || 20 | v.$type === 'app.bsky.graph.follow') 21 | ) 22 | } 23 | 24 | export function validateRecord(v: unknown): ValidationResult { 25 | return lexicons.validate('app.bsky.graph.follow#main', v) 26 | } 27 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/strongRef.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Main { 10 | uri: string 11 | cid: string 12 | [k: string]: unknown 13 | } 14 | 15 | export function isMain(v: unknown): v is Main { 16 | return ( 17 | isObj(v) && 18 | hasProp(v, '$type') && 19 | (v.$type === 'com.atproto.repo.strongRef#main' || 20 | v.$type === 'com.atproto.repo.strongRef') 21 | ) 22 | } 23 | 24 | export function validateMain(v: unknown): ValidationResult { 25 | return lexicons.validate('com.atproto.repo.strongRef#main', v) 26 | } 27 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/listblock.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Record { 10 | subject: string 11 | createdAt: string 12 | [k: string]: unknown 13 | } 14 | 15 | export function isRecord(v: unknown): v is Record { 16 | return ( 17 | isObj(v) && 18 | hasProp(v, '$type') && 19 | (v.$type === 'app.bsky.graph.listblock#main' || 20 | v.$type === 'app.bsky.graph.listblock') 21 | ) 22 | } 23 | 24 | export function validateRecord(v: unknown): ValidationResult { 25 | return lexicons.validate('app.bsky.graph.listblock#main', v) 26 | } 27 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/listitem.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Record { 10 | subject: string 11 | list: string 12 | createdAt: string 13 | [k: string]: unknown 14 | } 15 | 16 | export function isRecord(v: unknown): v is Record { 17 | return ( 18 | isObj(v) && 19 | hasProp(v, '$type') && 20 | (v.$type === 'app.bsky.graph.listitem#main' || 21 | v.$type === 'app.bsky.graph.listitem') 22 | ) 23 | } 24 | 25 | export function validateRecord(v: unknown): ValidationResult { 26 | return lexicons.validate('app.bsky.graph.listitem#main', v) 27 | } 28 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/like.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' 9 | 10 | export interface Record { 11 | subject: ComAtprotoRepoStrongRef.Main 12 | createdAt: string 13 | [k: string]: unknown 14 | } 15 | 16 | export function isRecord(v: unknown): v is Record { 17 | return ( 18 | isObj(v) && 19 | hasProp(v, '$type') && 20 | (v.$type === 'app.bsky.feed.like#main' || v.$type === 'app.bsky.feed.like') 21 | ) 22 | } 23 | 24 | export function validateRecord(v: unknown): ValidationResult { 25 | return lexicons.validate('app.bsky.feed.like#main', v) 26 | } 27 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/repost.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' 9 | 10 | export interface Record { 11 | subject: ComAtprotoRepoStrongRef.Main 12 | createdAt: string 13 | [k: string]: unknown 14 | } 15 | 16 | export function isRecord(v: unknown): v is Record { 17 | return ( 18 | isObj(v) && 19 | hasProp(v, '$type') && 20 | (v.$type === 'app.bsky.feed.repost#main' || 21 | v.$type === 'app.bsky.feed.repost') 22 | ) 23 | } 24 | 25 | export function validateRecord(v: unknown): ValidationResult { 26 | return lexicons.validate('app.bsky.feed.repost#main', v) 27 | } 28 | -------------------------------------------------------------------------------- /src/algos/whats-alf.ts: -------------------------------------------------------------------------------- 1 | import { QueryParams } from '../lexicon/types/app/bsky/feed/getFeedSkeleton' 2 | import { AppContext } from '../config' 3 | 4 | // max 15 chars 5 | export const shortname = 'whats-alf' 6 | 7 | export const handler = async (ctx: AppContext, params: QueryParams) => { 8 | let builder = ctx.db 9 | .selectFrom('post') 10 | .selectAll() 11 | .orderBy('indexedAt', 'desc') 12 | .orderBy('cid', 'desc') 13 | .limit(params.limit) 14 | 15 | if (params.cursor) { 16 | const timeStr = new Date(parseInt(params.cursor, 10)).toISOString() 17 | builder = builder.where('post.indexedAt', '<', timeStr) 18 | } 19 | const res = await builder.execute() 20 | 21 | const feed = res.map((row) => ({ 22 | post: row.uri, 23 | })) 24 | 25 | let cursor: string | undefined 26 | const last = res.at(-1) 27 | if (last) { 28 | cursor = new Date(last.indexedAt).getTime().toString(10) 29 | } 30 | 31 | return { 32 | cursor, 33 | feed, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/db/migrations.ts: -------------------------------------------------------------------------------- 1 | import { Kysely, Migration, MigrationProvider } from 'kysely' 2 | 3 | const migrations: Record = {} 4 | 5 | export const migrationProvider: MigrationProvider = { 6 | async getMigrations() { 7 | return migrations 8 | }, 9 | } 10 | 11 | migrations['001'] = { 12 | async up(db: Kysely) { 13 | await db.schema 14 | .createTable('post') 15 | .addColumn('uri', 'varchar', (col) => col.primaryKey()) 16 | .addColumn('cid', 'varchar', (col) => col.notNull()) 17 | .addColumn('indexedAt', 'varchar', (col) => col.notNull()) 18 | .execute() 19 | await db.schema 20 | .createTable('sub_state') 21 | .addColumn('service', 'varchar', (col) => col.primaryKey()) 22 | .addColumn('cursor', 'integer', (col) => col.notNull()) 23 | .execute() 24 | }, 25 | async down(db: Kysely) { 26 | await db.schema.dropTable('post').execute() 27 | await db.schema.dropTable('sub_state').execute() 28 | }, 29 | } 30 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/deleteSession.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | export type HandlerInput = undefined 15 | 16 | export interface HandlerError { 17 | status: number 18 | message?: string 19 | } 20 | 21 | export type HandlerOutput = HandlerError | void 22 | export type HandlerReqCtx = { 23 | auth: HA 24 | params: QueryParams 25 | input: HandlerInput 26 | req: express.Request 27 | res: express.Response 28 | } 29 | export type Handler = ( 30 | ctx: HandlerReqCtx, 31 | ) => Promise | HandlerOutput 32 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/requestAccountDelete.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | export type HandlerInput = undefined 15 | 16 | export interface HandlerError { 17 | status: number 18 | message?: string 19 | } 20 | 21 | export type HandlerOutput = HandlerError | void 22 | export type HandlerReqCtx = { 23 | auth: HA 24 | params: QueryParams 25 | input: HandlerInput 26 | req: express.Request 27 | res: express.Response 28 | } 29 | export type Handler = ( 30 | ctx: HandlerReqCtx, 31 | ) => Promise | HandlerOutput 32 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/profile.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 9 | 10 | export interface Record { 11 | displayName?: string 12 | description?: string 13 | avatar?: BlobRef 14 | banner?: BlobRef 15 | labels?: 16 | | ComAtprotoLabelDefs.SelfLabels 17 | | { $type: string; [k: string]: unknown } 18 | [k: string]: unknown 19 | } 20 | 21 | export function isRecord(v: unknown): v is Record { 22 | return ( 23 | isObj(v) && 24 | hasProp(v, '$type') && 25 | (v.$type === 'app.bsky.actor.profile#main' || 26 | v.$type === 'app.bsky.actor.profile') 27 | ) 28 | } 29 | 30 | export function validateRecord(v: unknown): ValidationResult { 31 | return lexicons.validate('app.bsky.actor.profile#main', v) 32 | } 33 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # Whichever port you want to run this on 2 | FEEDGEN_PORT=3000 3 | 4 | # Change this to use a different bind address 5 | FEEDGEN_LISTENHOST="localhost" 6 | 7 | # Set to something like db.sqlite to store persistently 8 | FEEDGEN_SQLITE_LOCATION=":memory:" 9 | 10 | # Don't change unless you're working in a different environment than the primary Bluesky network 11 | FEEDGEN_SUBSCRIPTION_ENDPOINT="wss://bsky.network" 12 | 13 | # Set this to the hostname that you intend to run the service at 14 | FEEDGEN_HOSTNAME="example.com" 15 | 16 | # Set this to the DID of the account you'll use to publish the feed 17 | # You can find your accounts DID by going to 18 | # https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${YOUR_HANDLE} 19 | FEEDGEN_PUBLISHER_DID="did:plc:abcde...." 20 | 21 | # Only use this if you want a service did different from did:web 22 | # FEEDGEN_SERVICE_DID="did:plc:abcde..." 23 | 24 | # Delay between reconnect attempts to the firehose subscription endpoint (in milliseconds) 25 | FEEDGEN_SUBSCRIPTION_RECONNECT_DELAY=3000 26 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/muteActor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | actor: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/unmuteActor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | actor: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/muteActorList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | list: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/unmuteActorList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | list: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/notification/updateSeen.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | seenAt: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/identity/updateHandle.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | handle: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/revokeAppPassword.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | name: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/requestPasswordReset.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | email: string 15 | [k: string]: unknown 16 | } 17 | 18 | export interface HandlerInput { 19 | encoding: 'application/json' 20 | body: InputSchema 21 | } 22 | 23 | export interface HandlerError { 24 | status: number 25 | message?: string 26 | } 27 | 28 | export type HandlerOutput = HandlerError | void 29 | export type HandlerReqCtx = { 30 | auth: HA 31 | params: QueryParams 32 | input: HandlerInput 33 | req: express.Request 34 | res: express.Response 35 | } 36 | export type Handler = ( 37 | ctx: HandlerReqCtx, 38 | ) => Promise | HandlerOutput 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023–2024 Bluesky PBC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/updateAccountHandle.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | did: string 15 | handle: string 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | } 28 | 29 | export type HandlerOutput = HandlerError | void 30 | export type HandlerReqCtx = { 31 | auth: HA 32 | params: QueryParams 33 | input: HandlerInput 34 | req: express.Request 35 | res: express.Response 36 | } 37 | export type Handler = ( 38 | ctx: HandlerReqCtx, 39 | ) => Promise | HandlerOutput 40 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/disableInviteCodes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | codes?: string[] 15 | accounts?: string[] 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | } 28 | 29 | export type HandlerOutput = HandlerError | void 30 | export type HandlerReqCtx = { 31 | auth: HA 32 | params: QueryParams 33 | input: HandlerInput 34 | req: express.Request 35 | res: express.Response 36 | } 37 | export type Handler = ( 38 | ctx: HandlerReqCtx, 39 | ) => Promise | HandlerOutput 40 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/generator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as AppBskyRichtextFacet from '../richtext/facet' 9 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 10 | 11 | export interface Record { 12 | did: string 13 | displayName: string 14 | description?: string 15 | descriptionFacets?: AppBskyRichtextFacet.Main[] 16 | avatar?: BlobRef 17 | labels?: 18 | | ComAtprotoLabelDefs.SelfLabels 19 | | { $type: string; [k: string]: unknown } 20 | createdAt: string 21 | [k: string]: unknown 22 | } 23 | 24 | export function isRecord(v: unknown): v is Record { 25 | return ( 26 | isObj(v) && 27 | hasProp(v, '$type') && 28 | (v.$type === 'app.bsky.feed.generator#main' || 29 | v.$type === 'app.bsky.feed.generator') 30 | ) 31 | } 32 | 33 | export function validateRecord(v: unknown): ValidationResult { 34 | return lexicons.validate('app.bsky.feed.generator#main', v) 35 | } 36 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** Hostname of the service that is notifying of update. */ 15 | hostname: string 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | } 28 | 29 | export type HandlerOutput = HandlerError | void 30 | export type HandlerReqCtx = { 31 | auth: HA 32 | params: QueryParams 33 | input: HandlerInput 34 | req: express.Request 35 | res: express.Response 36 | } 37 | export type Handler = ( 38 | ctx: HandlerReqCtx, 39 | ) => Promise | HandlerOutput 40 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/putPreferences.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams {} 13 | 14 | export interface InputSchema { 15 | preferences: AppBskyActorDefs.Preferences 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | } 28 | 29 | export type HandlerOutput = HandlerError | void 30 | export type HandlerReqCtx = { 31 | auth: HA 32 | params: QueryParams 33 | input: HandlerInput 34 | req: express.Request 35 | res: express.Response 36 | } 37 | export type Handler = ( 38 | ctx: HandlerReqCtx, 39 | ) => Promise | HandlerOutput 40 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/updateAccountEmail.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** The handle or DID of the repo. */ 15 | account: string 16 | email: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface HandlerInput { 21 | encoding: 'application/json' 22 | body: InputSchema 23 | } 24 | 25 | export interface HandlerError { 26 | status: number 27 | message?: string 28 | } 29 | 30 | export type HandlerOutput = HandlerError | void 31 | export type HandlerReqCtx = { 32 | auth: HA 33 | params: QueryParams 34 | input: HandlerInput 35 | req: express.Request 36 | res: express.Response 37 | } 38 | export type Handler = ( 39 | ctx: HandlerReqCtx, 40 | ) => Promise | HandlerOutput 41 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/resetPassword.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | token: string 15 | password: string 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | error?: 'ExpiredToken' | 'InvalidToken' 28 | } 29 | 30 | export type HandlerOutput = HandlerError | void 31 | export type HandlerReqCtx = { 32 | auth: HA 33 | params: QueryParams 34 | input: HandlerInput 35 | req: express.Request 36 | res: express.Response 37 | } 38 | export type Handler = ( 39 | ctx: HandlerReqCtx, 40 | ) => Promise | HandlerOutput 41 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/requestCrawl.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** Hostname of the service that is requesting to be crawled. */ 15 | hostname: string 16 | [k: string]: unknown 17 | } 18 | 19 | export interface HandlerInput { 20 | encoding: 'application/json' 21 | body: InputSchema 22 | } 23 | 24 | export interface HandlerError { 25 | status: number 26 | message?: string 27 | } 28 | 29 | export type HandlerOutput = HandlerError | void 30 | export type HandlerReqCtx = { 31 | auth: HA 32 | params: QueryParams 33 | input: HandlerInput 34 | req: express.Request 35 | res: express.Response 36 | } 37 | export type Handler = ( 38 | ctx: HandlerReqCtx, 39 | ) => Promise | HandlerOutput 40 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/deleteAccount.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | did: string 15 | password: string 16 | token: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface HandlerInput { 21 | encoding: 'application/json' 22 | body: InputSchema 23 | } 24 | 25 | export interface HandlerError { 26 | status: number 27 | message?: string 28 | error?: 'ExpiredToken' | 'InvalidToken' 29 | } 30 | 31 | export type HandlerOutput = HandlerError | void 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/methods/feed-generation.ts: -------------------------------------------------------------------------------- 1 | import { InvalidRequestError } from '@atproto/xrpc-server' 2 | import { Server } from '../lexicon' 3 | import { AppContext } from '../config' 4 | import algos from '../algos' 5 | import { validateAuth } from '../auth' 6 | import { AtUri } from '@atproto/syntax' 7 | 8 | export default function (server: Server, ctx: AppContext) { 9 | server.app.bsky.feed.getFeedSkeleton(async ({ params, req }) => { 10 | const feedUri = new AtUri(params.feed) 11 | const algo = algos[feedUri.rkey] 12 | if ( 13 | feedUri.hostname !== ctx.cfg.publisherDid || 14 | feedUri.collection !== 'app.bsky.feed.generator' || 15 | !algo 16 | ) { 17 | throw new InvalidRequestError( 18 | 'Unsupported algorithm', 19 | 'UnsupportedAlgorithm', 20 | ) 21 | } 22 | /** 23 | * Example of how to check auth if giving user-specific results: 24 | * 25 | * const requesterDid = await validateAuth( 26 | * req, 27 | * ctx.cfg.serviceDid, 28 | * ctx.didResolver, 29 | * ) 30 | */ 31 | 32 | const body = await algo(ctx, params) 33 | return { 34 | encoding: 'application/json', 35 | body: body, 36 | } 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/list.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as AppBskyGraphDefs from './defs' 9 | import * as AppBskyRichtextFacet from '../richtext/facet' 10 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 11 | 12 | export interface Record { 13 | purpose: AppBskyGraphDefs.ListPurpose 14 | name: string 15 | description?: string 16 | descriptionFacets?: AppBskyRichtextFacet.Main[] 17 | avatar?: BlobRef 18 | labels?: 19 | | ComAtprotoLabelDefs.SelfLabels 20 | | { $type: string; [k: string]: unknown } 21 | createdAt: string 22 | [k: string]: unknown 23 | } 24 | 25 | export function isRecord(v: unknown): v is Record { 26 | return ( 27 | isObj(v) && 28 | hasProp(v, '$type') && 29 | (v.$type === 'app.bsky.graph.list#main' || 30 | v.$type === 'app.bsky.graph.list') 31 | ) 32 | } 33 | 34 | export function validateRecord(v: unknown): ValidationResult { 35 | return lexicons.validate('app.bsky.graph.list#main', v) 36 | } 37 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/notification/registerPush.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | serviceDid: string 15 | token: string 16 | platform: 'ios' | 'android' | 'web' | (string & {}) 17 | appId: string 18 | [k: string]: unknown 19 | } 20 | 21 | export interface HandlerInput { 22 | encoding: 'application/json' 23 | body: InputSchema 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | } 30 | 31 | export type HandlerOutput = HandlerError | void 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/disableAccountInvites.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | account: string 15 | /** Additionally add a note describing why the invites were disabled */ 16 | note?: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface HandlerInput { 21 | encoding: 'application/json' 22 | body: InputSchema 23 | } 24 | 25 | export interface HandlerError { 26 | status: number 27 | message?: string 28 | } 29 | 30 | export type HandlerOutput = HandlerError | void 31 | export type HandlerReqCtx = { 32 | auth: HA 33 | params: QueryParams 34 | input: HandlerInput 35 | req: express.Request 36 | res: express.Response 37 | } 38 | export type Handler = ( 39 | ctx: HandlerReqCtx, 40 | ) => Promise | HandlerOutput 41 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/enableAccountInvites.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | account: string 15 | /** Additionally add a note describing why the invites were enabled */ 16 | note?: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface HandlerInput { 21 | encoding: 'application/json' 22 | body: InputSchema 23 | } 24 | 25 | export interface HandlerError { 26 | status: number 27 | message?: string 28 | } 29 | 30 | export type HandlerOutput = HandlerError | void 31 | export type HandlerReqCtx = { 32 | auth: HA 33 | params: QueryParams 34 | input: HandlerInput 35 | req: express.Request 36 | res: express.Response 37 | } 38 | export type Handler = ( 39 | ctx: HandlerReqCtx, 40 | ) => Promise | HandlerOutput 41 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getCheckout.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams { 13 | /** The DID of the repo. */ 14 | did: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | export type HandlerInput = undefined 19 | 20 | export interface HandlerSuccess { 21 | encoding: 'application/vnd.ipld.car' 22 | body: Uint8Array | stream.Readable 23 | headers?: { [key: string]: string } 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | } 30 | 31 | export type HandlerOutput = HandlerError | HandlerSuccess 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/getProfile.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | export type OutputSchema = AppBskyActorDefs.ProfileViewDetailed 18 | export type HandlerInput = undefined 19 | 20 | export interface HandlerSuccess { 21 | encoding: 'application/json' 22 | body: OutputSchema 23 | headers?: { [key: string]: string } 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | } 30 | 31 | export type HandlerOutput = HandlerError | HandlerSuccess 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getBlocks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams { 13 | /** The DID of the repo. */ 14 | did: string 15 | cids: string[] 16 | } 17 | 18 | export type InputSchema = undefined 19 | export type HandlerInput = undefined 20 | 21 | export interface HandlerSuccess { 22 | encoding: 'application/vnd.ipld.car' 23 | body: Uint8Array | stream.Readable 24 | headers?: { [key: string]: string } 25 | } 26 | 27 | export interface HandlerError { 28 | status: number 29 | message?: string 30 | } 31 | 32 | export type HandlerOutput = HandlerError | HandlerSuccess 33 | export type HandlerReqCtx = { 34 | auth: HA 35 | params: QueryParams 36 | input: HandlerInput 37 | req: express.Request 38 | res: express.Response 39 | } 40 | export type Handler = ( 41 | ctx: HandlerReqCtx, 42 | ) => Promise | HandlerOutput 43 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/notification/getUnreadCount.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | seenAt?: string 13 | } 14 | 15 | export type InputSchema = undefined 16 | 17 | export interface OutputSchema { 18 | count: number 19 | [k: string]: unknown 20 | } 21 | 22 | export type HandlerInput = undefined 23 | 24 | export interface HandlerSuccess { 25 | encoding: 'application/json' 26 | body: OutputSchema 27 | headers?: { [key: string]: string } 28 | } 29 | 30 | export interface HandlerError { 31 | status: number 32 | message?: string 33 | } 34 | 35 | export type HandlerOutput = HandlerError | HandlerSuccess 36 | export type HandlerReqCtx = { 37 | auth: HA 38 | params: QueryParams 39 | input: HandlerInput 40 | req: express.Request 41 | res: express.Response 42 | } 43 | export type Handler = ( 44 | ctx: HandlerReqCtx, 45 | ) => Promise | HandlerOutput 46 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/defs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface SkeletonSearchPost { 10 | uri: string 11 | [k: string]: unknown 12 | } 13 | 14 | export function isSkeletonSearchPost(v: unknown): v is SkeletonSearchPost { 15 | return ( 16 | isObj(v) && 17 | hasProp(v, '$type') && 18 | v.$type === 'app.bsky.unspecced.defs#skeletonSearchPost' 19 | ) 20 | } 21 | 22 | export function validateSkeletonSearchPost(v: unknown): ValidationResult { 23 | return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchPost', v) 24 | } 25 | 26 | export interface SkeletonSearchActor { 27 | did: string 28 | [k: string]: unknown 29 | } 30 | 31 | export function isSkeletonSearchActor(v: unknown): v is SkeletonSearchActor { 32 | return ( 33 | isObj(v) && 34 | hasProp(v, '$type') && 35 | v.$type === 'app.bsky.unspecced.defs#skeletonSearchActor' 36 | ) 37 | } 38 | 39 | export function validateSkeletonSearchActor(v: unknown): ValidationResult { 40 | return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchActor', v) 41 | } 42 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/getSession.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | 15 | export interface OutputSchema { 16 | handle: string 17 | did: string 18 | email?: string 19 | [k: string]: unknown 20 | } 21 | 22 | export type HandlerInput = undefined 23 | 24 | export interface HandlerSuccess { 25 | encoding: 'application/json' 26 | body: OutputSchema 27 | headers?: { [key: string]: string } 28 | } 29 | 30 | export interface HandlerError { 31 | status: number 32 | message?: string 33 | } 34 | 35 | export type HandlerOutput = HandlerError | HandlerSuccess 36 | export type HandlerReqCtx = { 37 | auth: HA 38 | params: QueryParams 39 | input: HandlerInput 40 | req: express.Request 41 | res: express.Response 42 | } 43 | export type Handler = ( 44 | ctx: HandlerReqCtx, 45 | ) => Promise | HandlerOutput 46 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getModerationAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | id: number 14 | } 15 | 16 | export type InputSchema = undefined 17 | export type OutputSchema = ComAtprotoAdminDefs.ActionViewDetail 18 | export type HandlerInput = undefined 19 | 20 | export interface HandlerSuccess { 21 | encoding: 'application/json' 22 | body: OutputSchema 23 | headers?: { [key: string]: string } 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | } 30 | 31 | export type HandlerOutput = HandlerError | HandlerSuccess 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getModerationReport.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | id: number 14 | } 15 | 16 | export type InputSchema = undefined 17 | export type OutputSchema = ComAtprotoAdminDefs.ReportViewDetail 18 | export type HandlerInput = undefined 19 | 20 | export interface HandlerSuccess { 21 | encoding: 'application/json' 22 | body: OutputSchema 23 | headers?: { [key: string]: string } 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | } 30 | 31 | export type HandlerOutput = HandlerError | HandlerSuccess 32 | export type HandlerReqCtx = { 33 | auth: HA 34 | params: QueryParams 35 | input: HandlerInput 36 | req: express.Request 37 | res: express.Response 38 | } 39 | export type Handler = ( 40 | ctx: HandlerReqCtx, 41 | ) => Promise | HandlerOutput 42 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getBlob.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams { 13 | /** The DID of the repo. */ 14 | did: string 15 | /** The CID of the blob to fetch */ 16 | cid: string 17 | } 18 | 19 | export type InputSchema = undefined 20 | export type HandlerInput = undefined 21 | 22 | export interface HandlerSuccess { 23 | encoding: '*/*' 24 | body: Uint8Array | stream.Readable 25 | headers?: { [key: string]: string } 26 | } 27 | 28 | export interface HandlerError { 29 | status: number 30 | message?: string 31 | } 32 | 33 | export type HandlerOutput = HandlerError | HandlerSuccess 34 | export type HandlerReqCtx = { 35 | auth: HA 36 | params: QueryParams 37 | input: HandlerInput 38 | req: express.Request 39 | res: express.Response 40 | } 41 | export type Handler = ( 42 | ctx: HandlerReqCtx, 43 | ) => Promise | HandlerOutput 44 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getRepo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | did: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | export type OutputSchema = ComAtprotoAdminDefs.RepoViewDetail 18 | export type HandlerInput = undefined 19 | 20 | export interface HandlerSuccess { 21 | encoding: 'application/json' 22 | body: OutputSchema 23 | headers?: { [key: string]: string } 24 | } 25 | 26 | export interface HandlerError { 27 | status: number 28 | message?: string 29 | error?: 'RepoNotFound' 30 | } 31 | 32 | export type HandlerOutput = HandlerError | HandlerSuccess 33 | export type HandlerReqCtx = { 34 | auth: HA 35 | params: QueryParams 36 | input: HandlerInput 37 | req: express.Request 38 | res: express.Response 39 | } 40 | export type Handler = ( 41 | ctx: HandlerReqCtx, 42 | ) => Promise | HandlerOutput 43 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/identity/resolveHandle.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The handle to resolve. */ 13 | handle: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | did: string 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | } 35 | 36 | export type HandlerOutput = HandlerError | HandlerSuccess 37 | export type HandlerReqCtx = { 38 | auth: HA 39 | params: QueryParams 40 | input: HandlerInput 41 | req: express.Request 42 | res: express.Response 43 | } 44 | export type Handler = ( 45 | ctx: HandlerReqCtx, 46 | ) => Promise | HandlerOutput 47 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/getPreferences.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams {} 13 | 14 | export type InputSchema = undefined 15 | 16 | export interface OutputSchema { 17 | preferences: AppBskyActorDefs.Preferences 18 | [k: string]: unknown 19 | } 20 | 21 | export type HandlerInput = undefined 22 | 23 | export interface HandlerSuccess { 24 | encoding: 'application/json' 25 | body: OutputSchema 26 | headers?: { [key: string]: string } 27 | } 28 | 29 | export interface HandlerError { 30 | status: number 31 | message?: string 32 | } 33 | 34 | export type HandlerOutput = HandlerError | HandlerSuccess 35 | export type HandlerReqCtx = { 36 | auth: HA 37 | params: QueryParams 38 | input: HandlerInput 39 | req: express.Request 40 | res: express.Response 41 | } 42 | export type Handler = ( 43 | ctx: HandlerReqCtx, 44 | ) => Promise | HandlerOutput 45 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getHead.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The DID of the repo. */ 13 | did: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | root: string 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | error?: 'HeadNotFound' 35 | } 36 | 37 | export type HandlerOutput = HandlerError | HandlerSuccess 38 | export type HandlerReqCtx = { 39 | auth: HA 40 | params: QueryParams 41 | input: HandlerInput 42 | req: express.Request 43 | res: express.Response 44 | } 45 | export type Handler = ( 46 | ctx: HandlerReqCtx, 47 | ) => Promise | HandlerOutput 48 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getPosts.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | uris: string[] 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | posts: AppBskyFeedDefs.PostView[] 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | } 35 | 36 | export type HandlerOutput = HandlerError | HandlerSuccess 37 | export type HandlerReqCtx = { 38 | auth: HA 39 | params: QueryParams 40 | input: HandlerInput 41 | req: express.Request 42 | res: express.Response 43 | } 44 | export type Handler = ( 45 | ctx: HandlerReqCtx, 46 | ) => Promise | HandlerOutput 47 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | uri: string 14 | cid?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | export type OutputSchema = ComAtprotoAdminDefs.RecordViewDetail 19 | export type HandlerInput = undefined 20 | 21 | export interface HandlerSuccess { 22 | encoding: 'application/json' 23 | body: OutputSchema 24 | headers?: { [key: string]: string } 25 | } 26 | 27 | export interface HandlerError { 28 | status: number 29 | message?: string 30 | error?: 'RecordNotFound' 31 | } 32 | 33 | export type HandlerOutput = HandlerError | HandlerSuccess 34 | export type HandlerReqCtx = { 35 | auth: HA 36 | params: QueryParams 37 | input: HandlerInput 38 | req: express.Request 39 | res: express.Response 40 | } 41 | export type Handler = ( 42 | ctx: HandlerReqCtx, 43 | ) => Promise | HandlerOutput 44 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getRepo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams { 13 | /** The DID of the repo. */ 14 | did: string 15 | /** The revision of the repo to catch up from. */ 16 | since?: string 17 | } 18 | 19 | export type InputSchema = undefined 20 | export type HandlerInput = undefined 21 | 22 | export interface HandlerSuccess { 23 | encoding: 'application/vnd.ipld.car' 24 | body: Uint8Array | stream.Readable 25 | headers?: { [key: string]: string } 26 | } 27 | 28 | export interface HandlerError { 29 | status: number 30 | message?: string 31 | } 32 | 33 | export type HandlerOutput = HandlerError | HandlerSuccess 34 | export type HandlerReqCtx = { 35 | auth: HA 36 | params: QueryParams 37 | input: HandlerInput 38 | req: express.Request 39 | res: express.Response 40 | } 41 | export type Handler = ( 42 | ctx: HandlerReqCtx, 43 | ) => Promise | HandlerOutput 44 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/uploadBlob.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams {} 13 | 14 | export type InputSchema = string | Uint8Array 15 | 16 | export interface OutputSchema { 17 | blob: BlobRef 18 | [k: string]: unknown 19 | } 20 | 21 | export interface HandlerInput { 22 | encoding: '*/*' 23 | body: stream.Readable 24 | } 25 | 26 | export interface HandlerSuccess { 27 | encoding: 'application/json' 28 | body: OutputSchema 29 | headers?: { [key: string]: string } 30 | } 31 | 32 | export interface HandlerError { 33 | status: number 34 | message?: string 35 | } 36 | 37 | export type HandlerOutput = HandlerError | HandlerSuccess 38 | export type HandlerReqCtx = { 39 | auth: HA 40 | params: QueryParams 41 | input: HandlerInput 42 | req: express.Request 43 | res: express.Response 44 | } 45 | export type Handler = ( 46 | ctx: HandlerReqCtx, 47 | ) => Promise | HandlerOutput 48 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getFeedGenerators.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | feeds: string[] 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | feeds: AppBskyFeedDefs.GeneratorView[] 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | } 35 | 36 | export type HandlerOutput = HandlerError | HandlerSuccess 37 | export type HandlerReqCtx = { 38 | auth: HA 39 | params: QueryParams 40 | input: HandlerInput 41 | req: express.Request 42 | res: express.Response 43 | } 44 | export type Handler = ( 45 | ctx: HandlerReqCtx, 46 | ) => Promise | HandlerOutput 47 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/getProfiles.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actors: string[] 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | profiles: AppBskyActorDefs.ProfileViewDetailed[] 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | } 35 | 36 | export type HandlerOutput = HandlerError | HandlerSuccess 37 | export type HandlerReqCtx = { 38 | auth: HA 39 | params: QueryParams 40 | input: HandlerInput 41 | req: express.Request 42 | res: express.Response 43 | } 44 | export type Handler = ( 45 | ctx: HandlerReqCtx, 46 | ) => Promise | HandlerOutput 47 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/refreshSession.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | 15 | export interface OutputSchema { 16 | accessJwt: string 17 | refreshJwt: string 18 | handle: string 19 | did: string 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | error?: 'AccountTakedown' 35 | } 36 | 37 | export type HandlerOutput = HandlerError | HandlerSuccess 38 | export type HandlerReqCtx = { 39 | auth: HA 40 | params: QueryParams 41 | input: HandlerInput 42 | req: express.Request 43 | res: express.Response 44 | } 45 | export type Handler = ( 46 | ctx: HandlerReqCtx, 47 | ) => Promise | HandlerOutput 48 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getLatestCommit.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The DID of the repo. */ 13 | did: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | cid: string 20 | rev: string 21 | [k: string]: unknown 22 | } 23 | 24 | export type HandlerInput = undefined 25 | 26 | export interface HandlerSuccess { 27 | encoding: 'application/json' 28 | body: OutputSchema 29 | headers?: { [key: string]: string } 30 | } 31 | 32 | export interface HandlerError { 33 | status: number 34 | message?: string 35 | error?: 'RepoNotFound' 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getSuggestedFollowsByActor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | suggestions: AppBskyActorDefs.ProfileView[] 20 | [k: string]: unknown 21 | } 22 | 23 | export type HandlerInput = undefined 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | } 35 | 36 | export type HandlerOutput = HandlerError | HandlerSuccess 37 | export type HandlerReqCtx = { 38 | auth: HA 39 | params: QueryParams 40 | input: HandlerInput 41 | req: express.Request 42 | res: express.Response 43 | } 44 | export type Handler = ( 45 | ctx: HandlerReqCtx, 46 | ) => Promise | HandlerOutput 47 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/getRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import stream from 'stream' 6 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 7 | import { lexicons } from '../../../../lexicons' 8 | import { isObj, hasProp } from '../../../../util' 9 | import { CID } from 'multiformats/cid' 10 | import { HandlerAuth } from '@atproto/xrpc-server' 11 | 12 | export interface QueryParams { 13 | /** The DID of the repo. */ 14 | did: string 15 | collection: string 16 | rkey: string 17 | /** An optional past commit CID. */ 18 | commit?: string 19 | } 20 | 21 | export type InputSchema = undefined 22 | export type HandlerInput = undefined 23 | 24 | export interface HandlerSuccess { 25 | encoding: 'application/vnd.ipld.car' 26 | body: Uint8Array | stream.Readable 27 | headers?: { [key: string]: string } 28 | } 29 | 30 | export interface HandlerError { 31 | status: number 32 | message?: string 33 | } 34 | 35 | export type HandlerOutput = HandlerError | HandlerSuccess 36 | export type HandlerReqCtx = { 37 | auth: HA 38 | params: QueryParams 39 | input: HandlerInput 40 | req: express.Request 41 | res: express.Response 42 | } 43 | export type Handler = ( 44 | ctx: HandlerReqCtx, 45 | ) => Promise | HandlerOutput 46 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/defs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface InviteCode { 10 | code: string 11 | available: number 12 | disabled: boolean 13 | forAccount: string 14 | createdBy: string 15 | createdAt: string 16 | uses: InviteCodeUse[] 17 | [k: string]: unknown 18 | } 19 | 20 | export function isInviteCode(v: unknown): v is InviteCode { 21 | return ( 22 | isObj(v) && 23 | hasProp(v, '$type') && 24 | v.$type === 'com.atproto.server.defs#inviteCode' 25 | ) 26 | } 27 | 28 | export function validateInviteCode(v: unknown): ValidationResult { 29 | return lexicons.validate('com.atproto.server.defs#inviteCode', v) 30 | } 31 | 32 | export interface InviteCodeUse { 33 | usedBy: string 34 | usedAt: string 35 | [k: string]: unknown 36 | } 37 | 38 | export function isInviteCodeUse(v: unknown): v is InviteCodeUse { 39 | return ( 40 | isObj(v) && 41 | hasProp(v, '$type') && 42 | v.$type === 'com.atproto.server.defs#inviteCodeUse' 43 | ) 44 | } 45 | 46 | export function validateInviteCodeUse(v: unknown): ValidationResult { 47 | return lexicons.validate('com.atproto.server.defs#inviteCodeUse', v) 48 | } 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getListMutes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyGraphDefs from './defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | lists: AppBskyGraphDefs.ListView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import dotenv from 'dotenv' 2 | import FeedGenerator from './server' 3 | 4 | const run = async () => { 5 | dotenv.config() 6 | const hostname = maybeStr(process.env.FEEDGEN_HOSTNAME) ?? 'example.com' 7 | const serviceDid = 8 | maybeStr(process.env.FEEDGEN_SERVICE_DID) ?? `did:web:${hostname}` 9 | const server = FeedGenerator.create({ 10 | port: maybeInt(process.env.FEEDGEN_PORT) ?? 3000, 11 | listenhost: maybeStr(process.env.FEEDGEN_LISTENHOST) ?? 'localhost', 12 | sqliteLocation: maybeStr(process.env.FEEDGEN_SQLITE_LOCATION) ?? ':memory:', 13 | subscriptionEndpoint: 14 | maybeStr(process.env.FEEDGEN_SUBSCRIPTION_ENDPOINT) ?? 15 | 'wss://bsky.network', 16 | publisherDid: 17 | maybeStr(process.env.FEEDGEN_PUBLISHER_DID) ?? 'did:example:alice', 18 | subscriptionReconnectDelay: 19 | maybeInt(process.env.FEEDGEN_SUBSCRIPTION_RECONNECT_DELAY) ?? 3000, 20 | hostname, 21 | serviceDid, 22 | }) 23 | await server.start() 24 | console.log( 25 | `🤖 running feed generator at http://${server.cfg.listenhost}:${server.cfg.port}`, 26 | ) 27 | } 28 | 29 | const maybeStr = (val?: string) => { 30 | if (!val) return undefined 31 | return val 32 | } 33 | 34 | const maybeInt = (val?: string) => { 35 | if (!val) return undefined 36 | const int = parseInt(val, 10) 37 | if (isNaN(int)) return undefined 38 | return int 39 | } 40 | 41 | run() 42 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getFeedGenerator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | feed: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | view: AppBskyFeedDefs.GeneratorView 20 | isOnline: boolean 21 | isValid: boolean 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getListBlocks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyGraphDefs from './defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | lists: AppBskyGraphDefs.ListView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/getSuggestions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | actors: AppBskyActorDefs.ProfileView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getSuggestedFeeds.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | feeds: AppBskyFeedDefs.GeneratorView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getBlocks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | blocks: AppBskyActorDefs.ProfileView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getMutes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | mutes: AppBskyActorDefs.ProfileView[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/createInviteCode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | useCount: number 15 | forAccount?: string 16 | [k: string]: unknown 17 | } 18 | 19 | export interface OutputSchema { 20 | code: string 21 | [k: string]: unknown 22 | } 23 | 24 | export interface HandlerInput { 25 | encoding: 'application/json' 26 | body: InputSchema 27 | } 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getLists.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyGraphDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | lists: AppBskyGraphDefs.ListView[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "feed-generator", 3 | "version": "1.0.0", 4 | "description": "atproto feed generator starter kit", 5 | "main": "index.js", 6 | "repository": "git@github.com:bluesky-social/feed-generator.git", 7 | "author": "dholms ", 8 | "license": "MIT", 9 | "scripts": { 10 | "publishFeed": "ts-node scripts/publishFeedGen.ts", 11 | "unpublishFeed": "ts-node scripts/unpublishFeedGen.ts", 12 | "start": "ts-node src/index.ts", 13 | "build": "tsc" 14 | }, 15 | "dependencies": { 16 | "@atproto/api": "^0.13.28", 17 | "@atproto/identity": "^0.2.1", 18 | "@atproto/lexicon": "^0.2.2", 19 | "@atproto/repo": "^0.3.2", 20 | "@atproto/syntax": "^0.1.2", 21 | "@atproto/xrpc-server": "^0.7.9", 22 | "better-sqlite3": "^11.3.0", 23 | "dotenv": "^16.0.3", 24 | "express": "^4.18.2", 25 | "kysely": "^0.27.4", 26 | "multiformats": "^9.9.0" 27 | }, 28 | "devDependencies": { 29 | "@types/better-sqlite3": "^7.6.11", 30 | "@types/express": "^4.17.17", 31 | "@types/node": "^20.1.2", 32 | "inquirer": "^12.0.1", 33 | "ts-node": "^10.9.1", 34 | "typescript": "^5.0.4" 35 | }, 36 | "engines": { 37 | "node": ">= 18", 38 | "yarn": "1" 39 | }, 40 | "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" 41 | } 42 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getActorFeeds.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feeds: AppBskyFeedDefs.GeneratorView[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getTimeline.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | algorithm?: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.FeedViewPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/sendEmail.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | recipientDid: string 15 | content: string 16 | subject?: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface OutputSchema { 21 | sent: boolean 22 | [k: string]: unknown 23 | } 24 | 25 | export interface HandlerInput { 26 | encoding: 'application/json' 27 | body: InputSchema 28 | } 29 | 30 | export interface HandlerSuccess { 31 | encoding: 'application/json' 32 | body: OutputSchema 33 | headers?: { [key: string]: string } 34 | } 35 | 36 | export interface HandlerError { 37 | status: number 38 | message?: string 39 | } 40 | 41 | export type HandlerOutput = HandlerError | HandlerSuccess 42 | export type HandlerReqCtx = { 43 | auth: HA 44 | params: QueryParams 45 | input: HandlerInput 46 | req: express.Request 47 | res: express.Response 48 | } 49 | export type Handler = ( 50 | ctx: HandlerReqCtx, 51 | ) => Promise | HandlerOutput 52 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/describeRepo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The handle or DID of the repo. */ 13 | repo: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | handle: string 20 | did: string 21 | didDoc: {} 22 | collections: string[] 23 | handleIsCorrect: boolean 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/getPopular.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from '../feed/defs' 11 | 12 | export interface QueryParams { 13 | includeNsfw: boolean 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.FeedViewPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getFeed.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | feed: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.FeedViewPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | error?: 'UnknownFeed' 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getModerationActions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | subject?: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | actions: ComAtprotoAdminDefs.ActionView[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getListFeed.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | list: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.FeedViewPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | error?: 'UnknownList' 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/getPopularFeedGenerators.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from '../feed/defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | query?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feeds: AppBskyFeedDefs.GeneratorView[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/getAccountInviteCodes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoServerDefs from './defs' 11 | 12 | export interface QueryParams { 13 | includeUsed: boolean 14 | createAvailable: boolean 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | codes: ComAtprotoServerDefs.InviteCode[] 21 | [k: string]: unknown 22 | } 23 | 24 | export type HandlerInput = undefined 25 | 26 | export interface HandlerSuccess { 27 | encoding: 'application/json' 28 | body: OutputSchema 29 | headers?: { [key: string]: string } 30 | } 31 | 32 | export interface HandlerError { 33 | status: number 34 | message?: string 35 | error?: 'DuplicateCreate' 36 | } 37 | 38 | export type HandlerOutput = HandlerError | HandlerSuccess 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/getTimelineSkeleton.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from '../feed/defs' 11 | 12 | export interface QueryParams { 13 | limit: number 14 | cursor?: string 15 | } 16 | 17 | export type InputSchema = undefined 18 | 19 | export interface OutputSchema { 20 | cursor?: string 21 | feed: AppBskyFeedDefs.SkeletonFeedPost[] 22 | [k: string]: unknown 23 | } 24 | 25 | export type HandlerInput = undefined 26 | 27 | export interface HandlerSuccess { 28 | encoding: 'application/json' 29 | body: OutputSchema 30 | headers?: { [key: string]: string } 31 | } 32 | 33 | export interface HandlerError { 34 | status: number 35 | message?: string 36 | error?: 'UnknownFeed' 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/reverseModerationAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams {} 13 | 14 | export interface InputSchema { 15 | id: number 16 | reason: string 17 | createdBy: string 18 | [k: string]: unknown 19 | } 20 | 21 | export type OutputSchema = ComAtprotoAdminDefs.ActionView 22 | 23 | export interface HandlerInput { 24 | encoding: 'application/json' 25 | body: InputSchema 26 | } 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getFeedSkeleton.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | feed: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.SkeletonFeedPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | error?: 'UnknownFeed' 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyGraphDefs from './defs' 11 | 12 | export interface QueryParams { 13 | list: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | list: AppBskyGraphDefs.ListView 23 | items: AppBskyGraphDefs.ListItemView[] 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/resolveModerationReports.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams {} 13 | 14 | export interface InputSchema { 15 | actionId: number 16 | reportIds: number[] 17 | createdBy: string 18 | [k: string]: unknown 19 | } 20 | 21 | export type OutputSchema = ComAtprotoAdminDefs.ActionView 22 | 23 | export interface HandlerInput { 24 | encoding: 'application/json' 25 | body: InputSchema 26 | } 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getActorLikes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | feed: AppBskyFeedDefs.FeedViewPost[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | error?: 'BlockedActor' | 'BlockedByActor' 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getInviteCodes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoServerDefs from '../server/defs' 11 | 12 | export interface QueryParams { 13 | sort: 'recent' | 'usage' | (string & {}) 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | cursor?: string 22 | codes: ComAtprotoServerDefs.InviteCode[] 23 | [k: string]: unknown 24 | } 25 | 26 | export type HandlerInput = undefined 27 | 28 | export interface HandlerSuccess { 29 | encoding: 'application/json' 30 | body: OutputSchema 31 | headers?: { [key: string]: string } 32 | } 33 | 34 | export interface HandlerError { 35 | status: number 36 | message?: string 37 | } 38 | 39 | export type HandlerOutput = HandlerError | HandlerSuccess 40 | export type HandlerReqCtx = { 41 | auth: HA 42 | params: QueryParams 43 | input: HandlerInput 44 | req: express.Request 45 | res: express.Response 46 | } 47 | export type Handler = ( 48 | ctx: HandlerReqCtx, 49 | ) => Promise | HandlerOutput 50 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/listBlobs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The DID of the repo. */ 13 | did: string 14 | /** Optional revision of the repo to list blobs since */ 15 | since?: string 16 | limit: number 17 | cursor?: string 18 | } 19 | 20 | export type InputSchema = undefined 21 | 22 | export interface OutputSchema { 23 | cursor?: string 24 | cids: string[] 25 | [k: string]: unknown 26 | } 27 | 28 | export type HandlerInput = undefined 29 | 30 | export interface HandlerSuccess { 31 | encoding: 'application/json' 32 | body: OutputSchema 33 | headers?: { [key: string]: string } 34 | } 35 | 36 | export interface HandlerError { 37 | status: number 38 | message?: string 39 | } 40 | 41 | export type HandlerOutput = HandlerError | HandlerSuccess 42 | export type HandlerReqCtx = { 43 | auth: HA 44 | params: QueryParams 45 | input: HandlerInput 46 | req: express.Request 47 | res: express.Response 48 | } 49 | export type Handler = ( 50 | ctx: HandlerReqCtx, 51 | ) => Promise | HandlerOutput 52 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getFollowers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | subject: AppBskyActorDefs.ProfileView 22 | cursor?: string 23 | followers: AppBskyActorDefs.ProfileView[] 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/getFollows.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | subject: AppBskyActorDefs.ProfileView 22 | cursor?: string 23 | follows: AppBskyActorDefs.ProfileView[] 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/moderation/defs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export type ReasonType = 10 | | 'com.atproto.moderation.defs#reasonSpam' 11 | | 'com.atproto.moderation.defs#reasonViolation' 12 | | 'com.atproto.moderation.defs#reasonMisleading' 13 | | 'com.atproto.moderation.defs#reasonSexual' 14 | | 'com.atproto.moderation.defs#reasonRude' 15 | | 'com.atproto.moderation.defs#reasonOther' 16 | | (string & {}) 17 | 18 | /** Spam: frequent unwanted promotion, replies, mentions */ 19 | export const REASONSPAM = 'com.atproto.moderation.defs#reasonSpam' 20 | /** Direct violation of server rules, laws, terms of service */ 21 | export const REASONVIOLATION = 'com.atproto.moderation.defs#reasonViolation' 22 | /** Misleading identity, affiliation, or content */ 23 | export const REASONMISLEADING = 'com.atproto.moderation.defs#reasonMisleading' 24 | /** Unwanted or mislabeled sexual content */ 25 | export const REASONSEXUAL = 'com.atproto.moderation.defs#reasonSexual' 26 | /** Rude, harassing, explicit, or otherwise unwelcoming behavior */ 27 | export const REASONRUDE = 'com.atproto.moderation.defs#reasonRude' 28 | /** Other: reports not falling under another report category */ 29 | export const REASONOTHER = 'com.atproto.moderation.defs#reasonOther' 30 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getRepostedBy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | uri: string 14 | cid?: string 15 | limit: number 16 | cursor?: string 17 | } 18 | 19 | export type InputSchema = undefined 20 | 21 | export interface OutputSchema { 22 | uri: string 23 | cid?: string 24 | cursor?: string 25 | repostedBy: AppBskyActorDefs.ProfileView[] 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | } 41 | 42 | export type HandlerOutput = HandlerError | HandlerSuccess 43 | export type HandlerReqCtx = { 44 | auth: HA 45 | params: QueryParams 46 | input: HandlerInput 47 | req: express.Request 48 | res: express.Response 49 | } 50 | export type Handler = ( 51 | ctx: HandlerReqCtx, 52 | ) => Promise | HandlerOutput 53 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/deleteRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** The handle or DID of the repo. */ 15 | repo: string 16 | /** The NSID of the record collection. */ 17 | collection: string 18 | /** The key of the record. */ 19 | rkey: string 20 | /** Compare and swap with the previous record by cid. */ 21 | swapRecord?: string 22 | /** Compare and swap with the previous commit by cid. */ 23 | swapCommit?: string 24 | [k: string]: unknown 25 | } 26 | 27 | export interface HandlerInput { 28 | encoding: 'application/json' 29 | body: InputSchema 30 | } 31 | 32 | export interface HandlerError { 33 | status: number 34 | message?: string 35 | error?: 'InvalidSwap' 36 | } 37 | 38 | export type HandlerOutput = HandlerError | void 39 | export type HandlerReqCtx = { 40 | auth: HA 41 | params: QueryParams 42 | input: HandlerInput 43 | req: express.Request 44 | res: express.Response 45 | } 46 | export type Handler = ( 47 | ctx: HandlerReqCtx, 48 | ) => Promise | HandlerOutput 49 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** DEPRECATED: use 'q' instead */ 14 | term?: string 15 | /** search query prefix; not a full query string */ 16 | q?: string 17 | limit: number 18 | } 19 | 20 | export type InputSchema = undefined 21 | 22 | export interface OutputSchema { 23 | actors: AppBskyActorDefs.ProfileViewBasic[] 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/searchRepos.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** DEPRECATED: use 'q' instead */ 14 | term?: string 15 | q?: string 16 | invitedBy?: string 17 | limit: number 18 | cursor?: string 19 | } 20 | 21 | export type InputSchema = undefined 22 | 23 | export interface OutputSchema { 24 | cursor?: string 25 | repos: ComAtprotoAdminDefs.RepoView[] 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | } 41 | 42 | export type HandlerOutput = HandlerError | HandlerSuccess 43 | export type HandlerReqCtx = { 44 | auth: HA 45 | params: QueryParams 46 | input: HandlerInput 47 | req: express.Request 48 | res: express.Response 49 | } 50 | export type Handler = ( 51 | ctx: HandlerReqCtx, 52 | ) => Promise | HandlerOutput 53 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getPostThread.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | uri: string 14 | depth: number 15 | parentHeight: number 16 | } 17 | 18 | export type InputSchema = undefined 19 | 20 | export interface OutputSchema { 21 | thread: 22 | | AppBskyFeedDefs.ThreadViewPost 23 | | AppBskyFeedDefs.NotFoundPost 24 | | AppBskyFeedDefs.BlockedPost 25 | | { $type: string; [k: string]: unknown } 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | error?: 'NotFound' 41 | } 42 | 43 | export type HandlerOutput = HandlerError | HandlerSuccess 44 | export type HandlerReqCtx = { 45 | auth: HA 46 | params: QueryParams 47 | input: HandlerInput 48 | req: express.Request 49 | res: express.Response 50 | } 51 | export type Handler = ( 52 | ctx: HandlerReqCtx, 53 | ) => Promise | HandlerOutput 54 | -------------------------------------------------------------------------------- /src/subscription.ts: -------------------------------------------------------------------------------- 1 | import { 2 | OutputSchema as RepoEvent, 3 | isCommit, 4 | } from './lexicon/types/com/atproto/sync/subscribeRepos' 5 | import { FirehoseSubscriptionBase, getOpsByType } from './util/subscription' 6 | 7 | export class FirehoseSubscription extends FirehoseSubscriptionBase { 8 | async handleEvent(evt: RepoEvent) { 9 | if (!isCommit(evt)) return 10 | 11 | const ops = await getOpsByType(evt) 12 | 13 | // This logs the text of every post off the firehose. 14 | // Just for fun :) 15 | // Delete before actually using 16 | for (const post of ops.posts.creates) { 17 | console.log(post.record.text) 18 | } 19 | 20 | const postsToDelete = ops.posts.deletes.map((del) => del.uri) 21 | const postsToCreate = ops.posts.creates 22 | .filter((create) => { 23 | // only alf-related posts 24 | return create.record.text.toLowerCase().includes('alf') 25 | }) 26 | .map((create) => { 27 | // map alf-related posts to a db row 28 | return { 29 | uri: create.uri, 30 | cid: create.cid, 31 | indexedAt: new Date().toISOString(), 32 | } 33 | }) 34 | 35 | if (postsToDelete.length > 0) { 36 | await this.db 37 | .deleteFrom('post') 38 | .where('uri', 'in', postsToDelete) 39 | .execute() 40 | } 41 | if (postsToCreate.length > 0) { 42 | await this.db 43 | .insertInto('post') 44 | .values(postsToCreate) 45 | .onConflict((oc) => oc.doNothing()) 46 | .execute() 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getAuthorFeed.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | actor: string 14 | limit: number 15 | cursor?: string 16 | filter: 17 | | 'posts_with_replies' 18 | | 'posts_no_replies' 19 | | 'posts_with_media' 20 | | (string & {}) 21 | } 22 | 23 | export type InputSchema = undefined 24 | 25 | export interface OutputSchema { 26 | cursor?: string 27 | feed: AppBskyFeedDefs.FeedViewPost[] 28 | [k: string]: unknown 29 | } 30 | 31 | export type HandlerInput = undefined 32 | 33 | export interface HandlerSuccess { 34 | encoding: 'application/json' 35 | body: OutputSchema 36 | headers?: { [key: string]: string } 37 | } 38 | 39 | export interface HandlerError { 40 | status: number 41 | message?: string 42 | error?: 'BlockedActor' | 'BlockedByActor' 43 | } 44 | 45 | export type HandlerOutput = HandlerError | HandlerSuccess 46 | export type HandlerReqCtx = { 47 | auth: HA 48 | params: QueryParams 49 | input: HandlerInput 50 | req: express.Request 51 | res: express.Response 52 | } 53 | export type Handler = ( 54 | ctx: HandlerReqCtx, 55 | ) => Promise | HandlerOutput 56 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/actor/searchActors.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** DEPRECATED: use 'q' instead */ 14 | term?: string 15 | /** search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended */ 16 | q?: string 17 | limit: number 18 | cursor?: string 19 | } 20 | 21 | export type InputSchema = undefined 22 | 23 | export interface OutputSchema { 24 | cursor?: string 25 | actors: AppBskyActorDefs.ProfileView[] 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | } 41 | 42 | export type HandlerOutput = HandlerError | HandlerSuccess 43 | export type HandlerReqCtx = { 44 | auth: HA 45 | params: QueryParams 46 | input: HandlerInput 47 | req: express.Request 48 | res: express.Response 49 | } 50 | export type Handler = ( 51 | ctx: HandlerReqCtx, 52 | ) => Promise | HandlerOutput 53 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/getRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The handle or DID of the repo. */ 13 | repo: string 14 | /** The NSID of the record collection. */ 15 | collection: string 16 | /** The key of the record. */ 17 | rkey: string 18 | /** The CID of the version of the record. If not specified, then return the most recent version. */ 19 | cid?: string 20 | } 21 | 22 | export type InputSchema = undefined 23 | 24 | export interface OutputSchema { 25 | uri: string 26 | cid?: string 27 | value: {} 28 | [k: string]: unknown 29 | } 30 | 31 | export type HandlerInput = undefined 32 | 33 | export interface HandlerSuccess { 34 | encoding: 'application/json' 35 | body: OutputSchema 36 | headers?: { [key: string]: string } 37 | } 38 | 39 | export interface HandlerError { 40 | status: number 41 | message?: string 42 | } 43 | 44 | export type HandlerOutput = HandlerError | HandlerSuccess 45 | export type HandlerReqCtx = { 46 | auth: HA 47 | params: QueryParams 48 | input: HandlerInput 49 | req: express.Request 50 | res: express.Response 51 | } 52 | export type Handler = ( 53 | ctx: HandlerReqCtx, 54 | ) => Promise | HandlerOutput 55 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/createSession.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** Handle or other identifier supported by the server for the authenticating user. */ 15 | identifier: string 16 | password: string 17 | [k: string]: unknown 18 | } 19 | 20 | export interface OutputSchema { 21 | accessJwt: string 22 | refreshJwt: string 23 | handle: string 24 | did: string 25 | email?: string 26 | [k: string]: unknown 27 | } 28 | 29 | export interface HandlerInput { 30 | encoding: 'application/json' 31 | body: InputSchema 32 | } 33 | 34 | export interface HandlerSuccess { 35 | encoding: 'application/json' 36 | body: OutputSchema 37 | headers?: { [key: string]: string } 38 | } 39 | 40 | export interface HandlerError { 41 | status: number 42 | message?: string 43 | error?: 'AccountTakedown' 44 | } 45 | 46 | export type HandlerOutput = HandlerError | HandlerSuccess 47 | export type HandlerReqCtx = { 48 | auth: HA 49 | params: QueryParams 50 | input: HandlerInput 51 | req: express.Request 52 | res: express.Response 53 | } 54 | export type Handler = ( 55 | ctx: HandlerReqCtx, 56 | ) => Promise | HandlerOutput 57 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/embed/recordWithMedia.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as AppBskyEmbedRecord from './record' 9 | import * as AppBskyEmbedImages from './images' 10 | import * as AppBskyEmbedExternal from './external' 11 | 12 | export interface Main { 13 | record: AppBskyEmbedRecord.Main 14 | media: 15 | | AppBskyEmbedImages.Main 16 | | AppBskyEmbedExternal.Main 17 | | { $type: string; [k: string]: unknown } 18 | [k: string]: unknown 19 | } 20 | 21 | export function isMain(v: unknown): v is Main { 22 | return ( 23 | isObj(v) && 24 | hasProp(v, '$type') && 25 | (v.$type === 'app.bsky.embed.recordWithMedia#main' || 26 | v.$type === 'app.bsky.embed.recordWithMedia') 27 | ) 28 | } 29 | 30 | export function validateMain(v: unknown): ValidationResult { 31 | return lexicons.validate('app.bsky.embed.recordWithMedia#main', v) 32 | } 33 | 34 | export interface View { 35 | record: AppBskyEmbedRecord.View 36 | media: 37 | | AppBskyEmbedImages.View 38 | | AppBskyEmbedExternal.View 39 | | { $type: string; [k: string]: unknown } 40 | [k: string]: unknown 41 | } 42 | 43 | export function isView(v: unknown): v is View { 44 | return ( 45 | isObj(v) && 46 | hasProp(v, '$type') && 47 | v.$type === 'app.bsky.embed.recordWithMedia#view' 48 | ) 49 | } 50 | 51 | export function validateView(v: unknown): ValidationResult { 52 | return lexicons.validate('app.bsky.embed.recordWithMedia#view', v) 53 | } 54 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/label/queryLabels.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoLabelDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** List of AT URI patterns to match (boolean 'OR'). Each may be a prefix (ending with '*'; will match inclusive of the string leading to '*'), or a full URI */ 14 | uriPatterns: string[] 15 | /** Optional list of label sources (DIDs) to filter on */ 16 | sources?: string[] 17 | limit: number 18 | cursor?: string 19 | } 20 | 21 | export type InputSchema = undefined 22 | 23 | export interface OutputSchema { 24 | cursor?: string 25 | labels: ComAtprotoLabelDefs.Label[] 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | } 41 | 42 | export type HandlerOutput = HandlerError | HandlerSuccess 43 | export type HandlerReqCtx = { 44 | auth: HA 45 | params: QueryParams 46 | input: HandlerInput 47 | req: express.Request 48 | res: express.Response 49 | } 50 | export type Handler = ( 51 | ctx: HandlerReqCtx, 52 | ) => Promise | HandlerOutput 53 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/sync/listRepos.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | limit: number 13 | cursor?: string 14 | } 15 | 16 | export type InputSchema = undefined 17 | 18 | export interface OutputSchema { 19 | cursor?: string 20 | repos: Repo[] 21 | [k: string]: unknown 22 | } 23 | 24 | export type HandlerInput = undefined 25 | 26 | export interface HandlerSuccess { 27 | encoding: 'application/json' 28 | body: OutputSchema 29 | headers?: { [key: string]: string } 30 | } 31 | 32 | export interface HandlerError { 33 | status: number 34 | message?: string 35 | } 36 | 37 | export type HandlerOutput = HandlerError | HandlerSuccess 38 | export type HandlerReqCtx = { 39 | auth: HA 40 | params: QueryParams 41 | input: HandlerInput 42 | req: express.Request 43 | res: express.Response 44 | } 45 | export type Handler = ( 46 | ctx: HandlerReqCtx, 47 | ) => Promise | HandlerOutput 48 | 49 | export interface Repo { 50 | did: string 51 | head: string 52 | [k: string]: unknown 53 | } 54 | 55 | export function isRepo(v: unknown): v is Repo { 56 | return ( 57 | isObj(v) && 58 | hasProp(v, '$type') && 59 | v.$type === 'com.atproto.sync.listRepos#repo' 60 | ) 61 | } 62 | 63 | export function validateRepo(v: unknown): ValidationResult { 64 | return lexicons.validate('com.atproto.sync.listRepos#repo', v) 65 | } 66 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/createAccount.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | email: string 15 | handle: string 16 | did?: string 17 | inviteCode?: string 18 | password: string 19 | recoveryKey?: string 20 | [k: string]: unknown 21 | } 22 | 23 | export interface OutputSchema { 24 | accessJwt: string 25 | refreshJwt: string 26 | handle: string 27 | did: string 28 | [k: string]: unknown 29 | } 30 | 31 | export interface HandlerInput { 32 | encoding: 'application/json' 33 | body: InputSchema 34 | } 35 | 36 | export interface HandlerSuccess { 37 | encoding: 'application/json' 38 | body: OutputSchema 39 | headers?: { [key: string]: string } 40 | } 41 | 42 | export interface HandlerError { 43 | status: number 44 | message?: string 45 | error?: 46 | | 'InvalidHandle' 47 | | 'InvalidPassword' 48 | | 'InvalidInviteCode' 49 | | 'HandleNotAvailable' 50 | | 'UnsupportedDomain' 51 | | 'UnresolvableDid' 52 | | 'IncompatibleDidDoc' 53 | } 54 | 55 | export type HandlerOutput = HandlerError | HandlerSuccess 56 | export type HandlerReqCtx = { 57 | auth: HA 58 | params: QueryParams 59 | input: HandlerInput 60 | req: express.Request 61 | res: express.Response 62 | } 63 | export type Handler = ( 64 | ctx: HandlerReqCtx, 65 | ) => Promise | HandlerOutput 66 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/createRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** The handle or DID of the repo. */ 15 | repo: string 16 | /** The NSID of the record collection. */ 17 | collection: string 18 | /** The key of the record. */ 19 | rkey?: string 20 | /** Validate the record? */ 21 | validate: boolean 22 | /** The record to create. */ 23 | record: {} 24 | /** Compare and swap with the previous commit by cid. */ 25 | swapCommit?: string 26 | [k: string]: unknown 27 | } 28 | 29 | export interface OutputSchema { 30 | uri: string 31 | cid: string 32 | [k: string]: unknown 33 | } 34 | 35 | export interface HandlerInput { 36 | encoding: 'application/json' 37 | body: InputSchema 38 | } 39 | 40 | export interface HandlerSuccess { 41 | encoding: 'application/json' 42 | body: OutputSchema 43 | headers?: { [key: string]: string } 44 | } 45 | 46 | export interface HandlerError { 47 | status: number 48 | message?: string 49 | error?: 'InvalidSwap' 50 | } 51 | 52 | export type HandlerOutput = HandlerError | HandlerSuccess 53 | export type HandlerReqCtx = { 54 | auth: HA 55 | params: QueryParams 56 | input: HandlerInput 57 | req: express.Request 58 | res: express.Response 59 | } 60 | export type Handler = ( 61 | ctx: HandlerReqCtx, 62 | ) => Promise | HandlerOutput 63 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/searchPosts.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyFeedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended */ 14 | q: string 15 | limit: number 16 | /** optional pagination mechanism; may not necessarily allow scrolling through entire result set */ 17 | cursor?: string 18 | } 19 | 20 | export type InputSchema = undefined 21 | 22 | export interface OutputSchema { 23 | cursor?: string 24 | /** count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits */ 25 | hitsTotal?: number 26 | posts: AppBskyFeedDefs.PostView[] 27 | [k: string]: unknown 28 | } 29 | 30 | export type HandlerInput = undefined 31 | 32 | export interface HandlerSuccess { 33 | encoding: 'application/json' 34 | body: OutputSchema 35 | headers?: { [key: string]: string } 36 | } 37 | 38 | export interface HandlerError { 39 | status: number 40 | message?: string 41 | error?: 'BadQueryString' 42 | } 43 | 44 | export type HandlerOutput = HandlerError | HandlerSuccess 45 | export type HandlerReqCtx = { 46 | auth: HA 47 | params: QueryParams 48 | input: HandlerInput 49 | req: express.Request 50 | res: express.Response 51 | } 52 | export type Handler = ( 53 | ctx: HandlerReqCtx, 54 | ) => Promise | HandlerOutput 55 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/listAppPasswords.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | 15 | export interface OutputSchema { 16 | passwords: AppPassword[] 17 | [k: string]: unknown 18 | } 19 | 20 | export type HandlerInput = undefined 21 | 22 | export interface HandlerSuccess { 23 | encoding: 'application/json' 24 | body: OutputSchema 25 | headers?: { [key: string]: string } 26 | } 27 | 28 | export interface HandlerError { 29 | status: number 30 | message?: string 31 | error?: 'AccountTakedown' 32 | } 33 | 34 | export type HandlerOutput = HandlerError | HandlerSuccess 35 | export type HandlerReqCtx = { 36 | auth: HA 37 | params: QueryParams 38 | input: HandlerInput 39 | req: express.Request 40 | res: express.Response 41 | } 42 | export type Handler = ( 43 | ctx: HandlerReqCtx, 44 | ) => Promise | HandlerOutput 45 | 46 | export interface AppPassword { 47 | name: string 48 | createdAt: string 49 | [k: string]: unknown 50 | } 51 | 52 | export function isAppPassword(v: unknown): v is AppPassword { 53 | return ( 54 | isObj(v) && 55 | hasProp(v, '$type') && 56 | v.$type === 'com.atproto.server.listAppPasswords#appPassword' 57 | ) 58 | } 59 | 60 | export function validateAppPassword(v: unknown): ValidationResult { 61 | return lexicons.validate('com.atproto.server.listAppPasswords#appPassword', v) 62 | } 63 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/describeServer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | 15 | export interface OutputSchema { 16 | inviteCodeRequired?: boolean 17 | availableUserDomains: string[] 18 | links?: Links 19 | [k: string]: unknown 20 | } 21 | 22 | export type HandlerInput = undefined 23 | 24 | export interface HandlerSuccess { 25 | encoding: 'application/json' 26 | body: OutputSchema 27 | headers?: { [key: string]: string } 28 | } 29 | 30 | export interface HandlerError { 31 | status: number 32 | message?: string 33 | } 34 | 35 | export type HandlerOutput = HandlerError | HandlerSuccess 36 | export type HandlerReqCtx = { 37 | auth: HA 38 | params: QueryParams 39 | input: HandlerInput 40 | req: express.Request 41 | res: express.Response 42 | } 43 | export type Handler = ( 44 | ctx: HandlerReqCtx, 45 | ) => Promise | HandlerOutput 46 | 47 | export interface Links { 48 | privacyPolicy?: string 49 | termsOfService?: string 50 | [k: string]: unknown 51 | } 52 | 53 | export function isLinks(v: unknown): v is Links { 54 | return ( 55 | isObj(v) && 56 | hasProp(v, '$type') && 57 | v.$type === 'com.atproto.server.describeServer#links' 58 | ) 59 | } 60 | 61 | export function validateLinks(v: unknown): ValidationResult { 62 | return lexicons.validate('com.atproto.server.describeServer#links', v) 63 | } 64 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyUnspeccedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended */ 14 | q: string 15 | limit: number 16 | /** optional pagination mechanism; may not necessarily allow scrolling through entire result set */ 17 | cursor?: string 18 | } 19 | 20 | export type InputSchema = undefined 21 | 22 | export interface OutputSchema { 23 | cursor?: string 24 | /** count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits */ 25 | hitsTotal?: number 26 | posts: AppBskyUnspeccedDefs.SkeletonSearchPost[] 27 | [k: string]: unknown 28 | } 29 | 30 | export type HandlerInput = undefined 31 | 32 | export interface HandlerSuccess { 33 | encoding: 'application/json' 34 | body: OutputSchema 35 | headers?: { [key: string]: string } 36 | } 37 | 38 | export interface HandlerError { 39 | status: number 40 | message?: string 41 | error?: 'BadQueryString' 42 | } 43 | 44 | export type HandlerOutput = HandlerError | HandlerSuccess 45 | export type HandlerReqCtx = { 46 | auth: HA 47 | params: QueryParams 48 | input: HandlerInput 49 | req: express.Request 50 | res: express.Response 51 | } 52 | export type Handler = ( 53 | ctx: HandlerReqCtx, 54 | ) => Promise | HandlerOutput 55 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/putRecord.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** The handle or DID of the repo. */ 15 | repo: string 16 | /** The NSID of the record collection. */ 17 | collection: string 18 | /** The key of the record. */ 19 | rkey: string 20 | /** Validate the record? */ 21 | validate: boolean 22 | /** The record to write. */ 23 | record: {} 24 | /** Compare and swap with the previous record by cid. */ 25 | swapRecord?: string | null 26 | /** Compare and swap with the previous commit by cid. */ 27 | swapCommit?: string 28 | [k: string]: unknown 29 | } 30 | 31 | export interface OutputSchema { 32 | uri: string 33 | cid: string 34 | [k: string]: unknown 35 | } 36 | 37 | export interface HandlerInput { 38 | encoding: 'application/json' 39 | body: InputSchema 40 | } 41 | 42 | export interface HandlerSuccess { 43 | encoding: 'application/json' 44 | body: OutputSchema 45 | headers?: { [key: string]: string } 46 | } 47 | 48 | export interface HandlerError { 49 | status: number 50 | message?: string 51 | error?: 'InvalidSwap' 52 | } 53 | 54 | export type HandlerOutput = HandlerError | HandlerSuccess 55 | export type HandlerReqCtx = { 56 | auth: HA 57 | params: QueryParams 58 | input: HandlerInput 59 | req: express.Request 60 | res: express.Response 61 | } 62 | export type Handler = ( 63 | ctx: HandlerReqCtx, 64 | ) => Promise | HandlerOutput 65 | -------------------------------------------------------------------------------- /scripts/unpublishFeedGen.ts: -------------------------------------------------------------------------------- 1 | import dotenv from 'dotenv' 2 | import { AtpAgent, BlobRef } from '@atproto/api' 3 | import fs from 'fs/promises' 4 | import { ids } from '../src/lexicon/lexicons' 5 | import inquirer from 'inquirer' 6 | 7 | const run = async () => { 8 | dotenv.config() 9 | 10 | const answers = await inquirer 11 | .prompt([ 12 | { 13 | type: 'input', 14 | name: 'handle', 15 | message: 'Enter your Bluesky handle', 16 | required: true, 17 | }, 18 | { 19 | type: 'password', 20 | name: 'password', 21 | message: 'Enter your Bluesky password (preferably an App Password):', 22 | }, 23 | { 24 | type: 'input', 25 | name: 'service', 26 | message: 'Optionally, enter a custom PDS service to sign in with:', 27 | default: 'https://bsky.social', 28 | required: false, 29 | }, 30 | { 31 | type: 'input', 32 | name: 'recordName', 33 | message: 'Enter the short name for the record you want to delete:', 34 | required: true, 35 | }, 36 | { 37 | type: 'confirm', 38 | name: 'confirm', 39 | message: 'Are you sure you want to delete this record? Any likes that your feed has will be lost:', 40 | default: false, 41 | } 42 | ]) 43 | 44 | const { handle, password, recordName, service, confirm } = answers 45 | 46 | if (!confirm) { 47 | console.log('Aborting...') 48 | return 49 | } 50 | 51 | // only update this if in a test environment 52 | const agent = new AtpAgent({ service: service ? service : 'https://bsky.social' }) 53 | await agent.login({ identifier: handle, password }) 54 | 55 | await agent.api.com.atproto.repo.deleteRecord({ 56 | repo: agent.session?.did ?? '', 57 | collection: ids.AppBskyFeedGenerator, 58 | rkey: recordName, 59 | }) 60 | 61 | console.log('All done 🎉') 62 | } 63 | 64 | run() 65 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/getLikes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | 12 | export interface QueryParams { 13 | uri: string 14 | cid?: string 15 | limit: number 16 | cursor?: string 17 | } 18 | 19 | export type InputSchema = undefined 20 | 21 | export interface OutputSchema { 22 | uri: string 23 | cid?: string 24 | cursor?: string 25 | likes: Like[] 26 | [k: string]: unknown 27 | } 28 | 29 | export type HandlerInput = undefined 30 | 31 | export interface HandlerSuccess { 32 | encoding: 'application/json' 33 | body: OutputSchema 34 | headers?: { [key: string]: string } 35 | } 36 | 37 | export interface HandlerError { 38 | status: number 39 | message?: string 40 | } 41 | 42 | export type HandlerOutput = HandlerError | HandlerSuccess 43 | export type HandlerReqCtx = { 44 | auth: HA 45 | params: QueryParams 46 | input: HandlerInput 47 | req: express.Request 48 | res: express.Response 49 | } 50 | export type Handler = ( 51 | ctx: HandlerReqCtx, 52 | ) => Promise | HandlerOutput 53 | 54 | export interface Like { 55 | indexedAt: string 56 | createdAt: string 57 | actor: AppBskyActorDefs.ProfileView 58 | [k: string]: unknown 59 | } 60 | 61 | export function isLike(v: unknown): v is Like { 62 | return ( 63 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.getLikes#like' 64 | ) 65 | } 66 | 67 | export function validateLike(v: unknown): ValidationResult { 68 | return lexicons.validate('app.bsky.feed.getLikes#like', v) 69 | } 70 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/createAppPassword.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | name: string 15 | [k: string]: unknown 16 | } 17 | 18 | export type OutputSchema = AppPassword 19 | 20 | export interface HandlerInput { 21 | encoding: 'application/json' 22 | body: InputSchema 23 | } 24 | 25 | export interface HandlerSuccess { 26 | encoding: 'application/json' 27 | body: OutputSchema 28 | headers?: { [key: string]: string } 29 | } 30 | 31 | export interface HandlerError { 32 | status: number 33 | message?: string 34 | error?: 'AccountTakedown' 35 | } 36 | 37 | export type HandlerOutput = HandlerError | HandlerSuccess 38 | export type HandlerReqCtx = { 39 | auth: HA 40 | params: QueryParams 41 | input: HandlerInput 42 | req: express.Request 43 | res: express.Response 44 | } 45 | export type Handler = ( 46 | ctx: HandlerReqCtx, 47 | ) => Promise | HandlerOutput 48 | 49 | export interface AppPassword { 50 | name: string 51 | password: string 52 | createdAt: string 53 | [k: string]: unknown 54 | } 55 | 56 | export function isAppPassword(v: unknown): v is AppPassword { 57 | return ( 58 | isObj(v) && 59 | hasProp(v, '$type') && 60 | v.$type === 'com.atproto.server.createAppPassword#appPassword' 61 | ) 62 | } 63 | 64 | export function validateAppPassword(v: unknown): ValidationResult { 65 | return lexicons.validate( 66 | 'com.atproto.server.createAppPassword#appPassword', 67 | v, 68 | ) 69 | } 70 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/server/createInviteCodes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | codeCount: number 15 | useCount: number 16 | forAccounts?: string[] 17 | [k: string]: unknown 18 | } 19 | 20 | export interface OutputSchema { 21 | codes: AccountCodes[] 22 | [k: string]: unknown 23 | } 24 | 25 | export interface HandlerInput { 26 | encoding: 'application/json' 27 | body: InputSchema 28 | } 29 | 30 | export interface HandlerSuccess { 31 | encoding: 'application/json' 32 | body: OutputSchema 33 | headers?: { [key: string]: string } 34 | } 35 | 36 | export interface HandlerError { 37 | status: number 38 | message?: string 39 | } 40 | 41 | export type HandlerOutput = HandlerError | HandlerSuccess 42 | export type HandlerReqCtx = { 43 | auth: HA 44 | params: QueryParams 45 | input: HandlerInput 46 | req: express.Request 47 | res: express.Response 48 | } 49 | export type Handler = ( 50 | ctx: HandlerReqCtx, 51 | ) => Promise | HandlerOutput 52 | 53 | export interface AccountCodes { 54 | account: string 55 | codes: string[] 56 | [k: string]: unknown 57 | } 58 | 59 | export function isAccountCodes(v: unknown): v is AccountCodes { 60 | return ( 61 | isObj(v) && 62 | hasProp(v, '$type') && 63 | v.$type === 'com.atproto.server.createInviteCodes#accountCodes' 64 | ) 65 | } 66 | 67 | export function validateAccountCodes(v: unknown): ValidationResult { 68 | return lexicons.validate( 69 | 'com.atproto.server.createInviteCodes#accountCodes', 70 | v, 71 | ) 72 | } 73 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyUnspeccedDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. For typeahead search, only simple term match is supported, not full syntax */ 14 | q: string 15 | /** if true, acts as fast/simple 'typeahead' query */ 16 | typeahead?: boolean 17 | limit: number 18 | /** optional pagination mechanism; may not necessarily allow scrolling through entire result set */ 19 | cursor?: string 20 | } 21 | 22 | export type InputSchema = undefined 23 | 24 | export interface OutputSchema { 25 | cursor?: string 26 | /** count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits */ 27 | hitsTotal?: number 28 | actors: AppBskyUnspeccedDefs.SkeletonSearchActor[] 29 | [k: string]: unknown 30 | } 31 | 32 | export type HandlerInput = undefined 33 | 34 | export interface HandlerSuccess { 35 | encoding: 'application/json' 36 | body: OutputSchema 37 | headers?: { [key: string]: string } 38 | } 39 | 40 | export interface HandlerError { 41 | status: number 42 | message?: string 43 | error?: 'BadQueryString' 44 | } 45 | 46 | export type HandlerOutput = HandlerError | HandlerSuccess 47 | export type HandlerReqCtx = { 48 | auth: HA 49 | params: QueryParams 50 | input: HandlerInput 51 | req: express.Request 52 | res: express.Response 53 | } 54 | export type Handler = ( 55 | ctx: HandlerReqCtx, 56 | ) => Promise | HandlerOutput 57 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/moderation/createReport.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoModerationDefs from './defs' 11 | import * as ComAtprotoAdminDefs from '../admin/defs' 12 | import * as ComAtprotoRepoStrongRef from '../repo/strongRef' 13 | 14 | export interface QueryParams {} 15 | 16 | export interface InputSchema { 17 | reasonType: ComAtprotoModerationDefs.ReasonType 18 | reason?: string 19 | subject: 20 | | ComAtprotoAdminDefs.RepoRef 21 | | ComAtprotoRepoStrongRef.Main 22 | | { $type: string; [k: string]: unknown } 23 | [k: string]: unknown 24 | } 25 | 26 | export interface OutputSchema { 27 | id: number 28 | reasonType: ComAtprotoModerationDefs.ReasonType 29 | reason?: string 30 | subject: 31 | | ComAtprotoAdminDefs.RepoRef 32 | | ComAtprotoRepoStrongRef.Main 33 | | { $type: string; [k: string]: unknown } 34 | reportedBy: string 35 | createdAt: string 36 | [k: string]: unknown 37 | } 38 | 39 | export interface HandlerInput { 40 | encoding: 'application/json' 41 | body: InputSchema 42 | } 43 | 44 | export interface HandlerSuccess { 45 | encoding: 'application/json' 46 | body: OutputSchema 47 | headers?: { [key: string]: string } 48 | } 49 | 50 | export interface HandlerError { 51 | status: number 52 | message?: string 53 | } 54 | 55 | export type HandlerOutput = HandlerError | HandlerSuccess 56 | export type HandlerReqCtx = { 57 | auth: HA 58 | params: QueryParams 59 | input: HandlerInput 60 | req: express.Request 61 | res: express.Response 62 | } 63 | export type Handler = ( 64 | ctx: HandlerReqCtx, 65 | ) => Promise | HandlerOutput 66 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/getModerationReports.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | 12 | export interface QueryParams { 13 | subject?: string 14 | ignoreSubjects?: string[] 15 | /** Get all reports that were actioned by a specific moderator */ 16 | actionedBy?: string 17 | /** Filter reports made by one or more DIDs */ 18 | reporters?: string[] 19 | resolved?: boolean 20 | actionType?: 21 | | 'com.atproto.admin.defs#takedown' 22 | | 'com.atproto.admin.defs#flag' 23 | | 'com.atproto.admin.defs#acknowledge' 24 | | 'com.atproto.admin.defs#escalate' 25 | | (string & {}) 26 | limit: number 27 | cursor?: string 28 | /** Reverse the order of the returned records? when true, returns reports in chronological order */ 29 | reverse?: boolean 30 | } 31 | 32 | export type InputSchema = undefined 33 | 34 | export interface OutputSchema { 35 | cursor?: string 36 | reports: ComAtprotoAdminDefs.ReportView[] 37 | [k: string]: unknown 38 | } 39 | 40 | export type HandlerInput = undefined 41 | 42 | export interface HandlerSuccess { 43 | encoding: 'application/json' 44 | body: OutputSchema 45 | headers?: { [key: string]: string } 46 | } 47 | 48 | export interface HandlerError { 49 | status: number 50 | message?: string 51 | } 52 | 53 | export type HandlerOutput = HandlerError | HandlerSuccess 54 | export type HandlerReqCtx = { 55 | auth: HA 56 | params: QueryParams 57 | input: HandlerInput 58 | req: express.Request 59 | res: express.Response 60 | } 61 | export type Handler = ( 62 | ctx: HandlerReqCtx, 63 | ) => Promise | HandlerOutput 64 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/admin/takeModerationAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as ComAtprotoAdminDefs from './defs' 11 | import * as ComAtprotoRepoStrongRef from '../repo/strongRef' 12 | 13 | export interface QueryParams {} 14 | 15 | export interface InputSchema { 16 | action: 17 | | 'com.atproto.admin.defs#takedown' 18 | | 'com.atproto.admin.defs#flag' 19 | | 'com.atproto.admin.defs#acknowledge' 20 | | (string & {}) 21 | subject: 22 | | ComAtprotoAdminDefs.RepoRef 23 | | ComAtprotoRepoStrongRef.Main 24 | | { $type: string; [k: string]: unknown } 25 | subjectBlobCids?: string[] 26 | createLabelVals?: string[] 27 | negateLabelVals?: string[] 28 | reason: string 29 | /** Indicates how long this action was meant to be in effect before automatically expiring. */ 30 | durationInHours?: number 31 | createdBy: string 32 | [k: string]: unknown 33 | } 34 | 35 | export type OutputSchema = ComAtprotoAdminDefs.ActionView 36 | 37 | export interface HandlerInput { 38 | encoding: 'application/json' 39 | body: InputSchema 40 | } 41 | 42 | export interface HandlerSuccess { 43 | encoding: 'application/json' 44 | body: OutputSchema 45 | headers?: { [key: string]: string } 46 | } 47 | 48 | export interface HandlerError { 49 | status: number 50 | message?: string 51 | error?: 'SubjectHasAction' 52 | } 53 | 54 | export type HandlerOutput = HandlerError | HandlerSuccess 55 | export type HandlerReqCtx = { 56 | auth: HA 57 | params: QueryParams 58 | input: HandlerInput 59 | req: express.Request 60 | res: express.Response 61 | } 62 | export type Handler = ( 63 | ctx: HandlerReqCtx, 64 | ) => Promise | HandlerOutput 65 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/label/subscribeLabels.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import { HandlerAuth, ErrorFrame } from '@atproto/xrpc-server' 9 | import { IncomingMessage } from 'http' 10 | import * as ComAtprotoLabelDefs from './defs' 11 | 12 | export interface QueryParams { 13 | /** The last known event to backfill from. */ 14 | cursor?: number 15 | } 16 | 17 | export type OutputSchema = 18 | | Labels 19 | | Info 20 | | { $type: string; [k: string]: unknown } 21 | export type HandlerError = ErrorFrame<'FutureCursor'> 22 | export type HandlerOutput = HandlerError | OutputSchema 23 | export type HandlerReqCtx = { 24 | auth: HA 25 | params: QueryParams 26 | req: IncomingMessage 27 | signal: AbortSignal 28 | } 29 | export type Handler = ( 30 | ctx: HandlerReqCtx, 31 | ) => AsyncIterable 32 | 33 | export interface Labels { 34 | seq: number 35 | labels: ComAtprotoLabelDefs.Label[] 36 | [k: string]: unknown 37 | } 38 | 39 | export function isLabels(v: unknown): v is Labels { 40 | return ( 41 | isObj(v) && 42 | hasProp(v, '$type') && 43 | v.$type === 'com.atproto.label.subscribeLabels#labels' 44 | ) 45 | } 46 | 47 | export function validateLabels(v: unknown): ValidationResult { 48 | return lexicons.validate('com.atproto.label.subscribeLabels#labels', v) 49 | } 50 | 51 | export interface Info { 52 | name: 'OutdatedCursor' | (string & {}) 53 | message?: string 54 | [k: string]: unknown 55 | } 56 | 57 | export function isInfo(v: unknown): v is Info { 58 | return ( 59 | isObj(v) && 60 | hasProp(v, '$type') && 61 | v.$type === 'com.atproto.label.subscribeLabels#info' 62 | ) 63 | } 64 | 65 | export function validateInfo(v: unknown): ValidationResult { 66 | return lexicons.validate('com.atproto.label.subscribeLabels#info', v) 67 | } 68 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/describeFeedGenerator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export type InputSchema = undefined 14 | 15 | export interface OutputSchema { 16 | did: string 17 | feeds: Feed[] 18 | links?: Links 19 | [k: string]: unknown 20 | } 21 | 22 | export type HandlerInput = undefined 23 | 24 | export interface HandlerSuccess { 25 | encoding: 'application/json' 26 | body: OutputSchema 27 | headers?: { [key: string]: string } 28 | } 29 | 30 | export interface HandlerError { 31 | status: number 32 | message?: string 33 | } 34 | 35 | export type HandlerOutput = HandlerError | HandlerSuccess 36 | export type HandlerReqCtx = { 37 | auth: HA 38 | params: QueryParams 39 | input: HandlerInput 40 | req: express.Request 41 | res: express.Response 42 | } 43 | export type Handler = ( 44 | ctx: HandlerReqCtx, 45 | ) => Promise | HandlerOutput 46 | 47 | export interface Feed { 48 | uri: string 49 | [k: string]: unknown 50 | } 51 | 52 | export function isFeed(v: unknown): v is Feed { 53 | return ( 54 | isObj(v) && 55 | hasProp(v, '$type') && 56 | v.$type === 'app.bsky.feed.describeFeedGenerator#feed' 57 | ) 58 | } 59 | 60 | export function validateFeed(v: unknown): ValidationResult { 61 | return lexicons.validate('app.bsky.feed.describeFeedGenerator#feed', v) 62 | } 63 | 64 | export interface Links { 65 | privacyPolicy?: string 66 | termsOfService?: string 67 | [k: string]: unknown 68 | } 69 | 70 | export function isLinks(v: unknown): v is Links { 71 | return ( 72 | isObj(v) && 73 | hasProp(v, '$type') && 74 | v.$type === 'app.bsky.feed.describeFeedGenerator#links' 75 | ) 76 | } 77 | 78 | export function validateLinks(v: unknown): ValidationResult { 79 | return lexicons.validate('app.bsky.feed.describeFeedGenerator#links', v) 80 | } 81 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/embed/external.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Main { 10 | external: External 11 | [k: string]: unknown 12 | } 13 | 14 | export function isMain(v: unknown): v is Main { 15 | return ( 16 | isObj(v) && 17 | hasProp(v, '$type') && 18 | (v.$type === 'app.bsky.embed.external#main' || 19 | v.$type === 'app.bsky.embed.external') 20 | ) 21 | } 22 | 23 | export function validateMain(v: unknown): ValidationResult { 24 | return lexicons.validate('app.bsky.embed.external#main', v) 25 | } 26 | 27 | export interface External { 28 | uri: string 29 | title: string 30 | description: string 31 | thumb?: BlobRef 32 | [k: string]: unknown 33 | } 34 | 35 | export function isExternal(v: unknown): v is External { 36 | return ( 37 | isObj(v) && 38 | hasProp(v, '$type') && 39 | v.$type === 'app.bsky.embed.external#external' 40 | ) 41 | } 42 | 43 | export function validateExternal(v: unknown): ValidationResult { 44 | return lexicons.validate('app.bsky.embed.external#external', v) 45 | } 46 | 47 | export interface View { 48 | external: ViewExternal 49 | [k: string]: unknown 50 | } 51 | 52 | export function isView(v: unknown): v is View { 53 | return ( 54 | isObj(v) && 55 | hasProp(v, '$type') && 56 | v.$type === 'app.bsky.embed.external#view' 57 | ) 58 | } 59 | 60 | export function validateView(v: unknown): ValidationResult { 61 | return lexicons.validate('app.bsky.embed.external#view', v) 62 | } 63 | 64 | export interface ViewExternal { 65 | uri: string 66 | title: string 67 | description: string 68 | thumb?: string 69 | [k: string]: unknown 70 | } 71 | 72 | export function isViewExternal(v: unknown): v is ViewExternal { 73 | return ( 74 | isObj(v) && 75 | hasProp(v, '$type') && 76 | v.$type === 'app.bsky.embed.external#viewExternal' 77 | ) 78 | } 79 | 80 | export function validateViewExternal(v: unknown): ValidationResult { 81 | return lexicons.validate('app.bsky.embed.external#viewExternal', v) 82 | } 83 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/listRecords.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams { 12 | /** The handle or DID of the repo. */ 13 | repo: string 14 | /** The NSID of the record type. */ 15 | collection: string 16 | /** The number of records to return. */ 17 | limit: number 18 | cursor?: string 19 | /** DEPRECATED: The lowest sort-ordered rkey to start from (exclusive) */ 20 | rkeyStart?: string 21 | /** DEPRECATED: The highest sort-ordered rkey to stop at (exclusive) */ 22 | rkeyEnd?: string 23 | /** Reverse the order of the returned records? */ 24 | reverse?: boolean 25 | } 26 | 27 | export type InputSchema = undefined 28 | 29 | export interface OutputSchema { 30 | cursor?: string 31 | records: Record[] 32 | [k: string]: unknown 33 | } 34 | 35 | export type HandlerInput = undefined 36 | 37 | export interface HandlerSuccess { 38 | encoding: 'application/json' 39 | body: OutputSchema 40 | headers?: { [key: string]: string } 41 | } 42 | 43 | export interface HandlerError { 44 | status: number 45 | message?: string 46 | } 47 | 48 | export type HandlerOutput = HandlerError | HandlerSuccess 49 | export type HandlerReqCtx = { 50 | auth: HA 51 | params: QueryParams 52 | input: HandlerInput 53 | req: express.Request 54 | res: express.Response 55 | } 56 | export type Handler = ( 57 | ctx: HandlerReqCtx, 58 | ) => Promise | HandlerOutput 59 | 60 | export interface Record { 61 | uri: string 62 | cid: string 63 | value: {} 64 | [k: string]: unknown 65 | } 66 | 67 | export function isRecord(v: unknown): v is Record { 68 | return ( 69 | isObj(v) && 70 | hasProp(v, '$type') && 71 | v.$type === 'com.atproto.repo.listRecords#record' 72 | ) 73 | } 74 | 75 | export function validateRecord(v: unknown): ValidationResult { 76 | return lexicons.validate('com.atproto.repo.listRecords#record', v) 77 | } 78 | -------------------------------------------------------------------------------- /src/server.ts: -------------------------------------------------------------------------------- 1 | import http from 'http' 2 | import events from 'events' 3 | import express from 'express' 4 | import { DidResolver, MemoryCache } from '@atproto/identity' 5 | import { createServer } from './lexicon' 6 | import feedGeneration from './methods/feed-generation' 7 | import describeGenerator from './methods/describe-generator' 8 | import { createDb, Database, migrateToLatest } from './db' 9 | import { FirehoseSubscription } from './subscription' 10 | import { AppContext, Config } from './config' 11 | import wellKnown from './well-known' 12 | 13 | export class FeedGenerator { 14 | public app: express.Application 15 | public server?: http.Server 16 | public db: Database 17 | public firehose: FirehoseSubscription 18 | public cfg: Config 19 | 20 | constructor( 21 | app: express.Application, 22 | db: Database, 23 | firehose: FirehoseSubscription, 24 | cfg: Config, 25 | ) { 26 | this.app = app 27 | this.db = db 28 | this.firehose = firehose 29 | this.cfg = cfg 30 | } 31 | 32 | static create(cfg: Config) { 33 | const app = express() 34 | const db = createDb(cfg.sqliteLocation) 35 | const firehose = new FirehoseSubscription(db, cfg.subscriptionEndpoint) 36 | 37 | const didCache = new MemoryCache() 38 | const didResolver = new DidResolver({ 39 | plcUrl: 'https://plc.directory', 40 | didCache, 41 | }) 42 | 43 | const server = createServer({ 44 | validateResponse: true, 45 | payload: { 46 | jsonLimit: 100 * 1024, // 100kb 47 | textLimit: 100 * 1024, // 100kb 48 | blobLimit: 5 * 1024 * 1024, // 5mb 49 | }, 50 | }) 51 | const ctx: AppContext = { 52 | db, 53 | didResolver, 54 | cfg, 55 | } 56 | feedGeneration(server, ctx) 57 | describeGenerator(server, ctx) 58 | app.use(server.xrpc.router) 59 | app.use(wellKnown(ctx)) 60 | 61 | return new FeedGenerator(app, db, firehose, cfg) 62 | } 63 | 64 | async start(): Promise { 65 | await migrateToLatest(this.db) 66 | this.firehose.run(this.cfg.subscriptionReconnectDelay) 67 | this.server = this.app.listen(this.cfg.port, this.cfg.listenhost) 68 | await events.once(this.server, 'listening') 69 | return this.server 70 | } 71 | } 72 | 73 | export default FeedGenerator 74 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/threadgate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Record { 10 | post: string 11 | allow?: ( 12 | | MentionRule 13 | | FollowingRule 14 | | ListRule 15 | | { $type: string; [k: string]: unknown } 16 | )[] 17 | createdAt: string 18 | [k: string]: unknown 19 | } 20 | 21 | export function isRecord(v: unknown): v is Record { 22 | return ( 23 | isObj(v) && 24 | hasProp(v, '$type') && 25 | (v.$type === 'app.bsky.feed.threadgate#main' || 26 | v.$type === 'app.bsky.feed.threadgate') 27 | ) 28 | } 29 | 30 | export function validateRecord(v: unknown): ValidationResult { 31 | return lexicons.validate('app.bsky.feed.threadgate#main', v) 32 | } 33 | 34 | /** Allow replies from actors mentioned in your post. */ 35 | export interface MentionRule { 36 | [k: string]: unknown 37 | } 38 | 39 | export function isMentionRule(v: unknown): v is MentionRule { 40 | return ( 41 | isObj(v) && 42 | hasProp(v, '$type') && 43 | v.$type === 'app.bsky.feed.threadgate#mentionRule' 44 | ) 45 | } 46 | 47 | export function validateMentionRule(v: unknown): ValidationResult { 48 | return lexicons.validate('app.bsky.feed.threadgate#mentionRule', v) 49 | } 50 | 51 | /** Allow replies from actors you follow. */ 52 | export interface FollowingRule { 53 | [k: string]: unknown 54 | } 55 | 56 | export function isFollowingRule(v: unknown): v is FollowingRule { 57 | return ( 58 | isObj(v) && 59 | hasProp(v, '$type') && 60 | v.$type === 'app.bsky.feed.threadgate#followingRule' 61 | ) 62 | } 63 | 64 | export function validateFollowingRule(v: unknown): ValidationResult { 65 | return lexicons.validate('app.bsky.feed.threadgate#followingRule', v) 66 | } 67 | 68 | /** Allow replies from actors on a list. */ 69 | export interface ListRule { 70 | list: string 71 | [k: string]: unknown 72 | } 73 | 74 | export function isListRule(v: unknown): v is ListRule { 75 | return ( 76 | isObj(v) && 77 | hasProp(v, '$type') && 78 | v.$type === 'app.bsky.feed.threadgate#listRule' 79 | ) 80 | } 81 | 82 | export function validateListRule(v: unknown): ValidationResult { 83 | return lexicons.validate('app.bsky.feed.threadgate#listRule', v) 84 | } 85 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/notification/listNotifications.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | import * as AppBskyActorDefs from '../actor/defs' 11 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 12 | 13 | export interface QueryParams { 14 | limit: number 15 | cursor?: string 16 | seenAt?: string 17 | } 18 | 19 | export type InputSchema = undefined 20 | 21 | export interface OutputSchema { 22 | cursor?: string 23 | notifications: Notification[] 24 | [k: string]: unknown 25 | } 26 | 27 | export type HandlerInput = undefined 28 | 29 | export interface HandlerSuccess { 30 | encoding: 'application/json' 31 | body: OutputSchema 32 | headers?: { [key: string]: string } 33 | } 34 | 35 | export interface HandlerError { 36 | status: number 37 | message?: string 38 | } 39 | 40 | export type HandlerOutput = HandlerError | HandlerSuccess 41 | export type HandlerReqCtx = { 42 | auth: HA 43 | params: QueryParams 44 | input: HandlerInput 45 | req: express.Request 46 | res: express.Response 47 | } 48 | export type Handler = ( 49 | ctx: HandlerReqCtx, 50 | ) => Promise | HandlerOutput 51 | 52 | export interface Notification { 53 | uri: string 54 | cid: string 55 | author: AppBskyActorDefs.ProfileView 56 | /** Expected values are 'like', 'repost', 'follow', 'mention', 'reply', and 'quote'. */ 57 | reason: 58 | | 'like' 59 | | 'repost' 60 | | 'follow' 61 | | 'mention' 62 | | 'reply' 63 | | 'quote' 64 | | (string & {}) 65 | reasonSubject?: string 66 | record: {} 67 | isRead: boolean 68 | indexedAt: string 69 | labels?: ComAtprotoLabelDefs.Label[] 70 | [k: string]: unknown 71 | } 72 | 73 | export function isNotification(v: unknown): v is Notification { 74 | return ( 75 | isObj(v) && 76 | hasProp(v, '$type') && 77 | v.$type === 'app.bsky.notification.listNotifications#notification' 78 | ) 79 | } 80 | 81 | export function validateNotification(v: unknown): ValidationResult { 82 | return lexicons.validate( 83 | 'app.bsky.notification.listNotifications#notification', 84 | v, 85 | ) 86 | } 87 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/label/defs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | /** Metadata tag on an atproto resource (eg, repo or record) */ 10 | export interface Label { 11 | /** DID of the actor who created this label */ 12 | src: string 13 | /** AT URI of the record, repository (account), or other resource which this label applies to */ 14 | uri: string 15 | /** optionally, CID specifying the specific version of 'uri' resource this label applies to */ 16 | cid?: string 17 | /** the short string name of the value or type of this label */ 18 | val: string 19 | /** if true, this is a negation label, overwriting a previous label */ 20 | neg?: boolean 21 | /** timestamp when this label was created */ 22 | cts: string 23 | [k: string]: unknown 24 | } 25 | 26 | export function isLabel(v: unknown): v is Label { 27 | return ( 28 | isObj(v) && 29 | hasProp(v, '$type') && 30 | v.$type === 'com.atproto.label.defs#label' 31 | ) 32 | } 33 | 34 | export function validateLabel(v: unknown): ValidationResult { 35 | return lexicons.validate('com.atproto.label.defs#label', v) 36 | } 37 | 38 | /** Metadata tags on an atproto record, published by the author within the record. */ 39 | export interface SelfLabels { 40 | values: SelfLabel[] 41 | [k: string]: unknown 42 | } 43 | 44 | export function isSelfLabels(v: unknown): v is SelfLabels { 45 | return ( 46 | isObj(v) && 47 | hasProp(v, '$type') && 48 | v.$type === 'com.atproto.label.defs#selfLabels' 49 | ) 50 | } 51 | 52 | export function validateSelfLabels(v: unknown): ValidationResult { 53 | return lexicons.validate('com.atproto.label.defs#selfLabels', v) 54 | } 55 | 56 | /** Metadata tag on an atproto record, published by the author within the record. Note -- schemas should use #selfLabels, not #selfLabel. */ 57 | export interface SelfLabel { 58 | /** the short string name of the value or type of this label */ 59 | val: string 60 | [k: string]: unknown 61 | } 62 | 63 | export function isSelfLabel(v: unknown): v is SelfLabel { 64 | return ( 65 | isObj(v) && 66 | hasProp(v, '$type') && 67 | v.$type === 'com.atproto.label.defs#selfLabel' 68 | ) 69 | } 70 | 71 | export function validateSelfLabel(v: unknown): ValidationResult { 72 | return lexicons.validate('com.atproto.label.defs#selfLabel', v) 73 | } 74 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/embed/images.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Main { 10 | images: Image[] 11 | [k: string]: unknown 12 | } 13 | 14 | export function isMain(v: unknown): v is Main { 15 | return ( 16 | isObj(v) && 17 | hasProp(v, '$type') && 18 | (v.$type === 'app.bsky.embed.images#main' || 19 | v.$type === 'app.bsky.embed.images') 20 | ) 21 | } 22 | 23 | export function validateMain(v: unknown): ValidationResult { 24 | return lexicons.validate('app.bsky.embed.images#main', v) 25 | } 26 | 27 | export interface Image { 28 | image: BlobRef 29 | alt: string 30 | aspectRatio?: AspectRatio 31 | [k: string]: unknown 32 | } 33 | 34 | export function isImage(v: unknown): v is Image { 35 | return ( 36 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#image' 37 | ) 38 | } 39 | 40 | export function validateImage(v: unknown): ValidationResult { 41 | return lexicons.validate('app.bsky.embed.images#image', v) 42 | } 43 | 44 | /** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */ 45 | export interface AspectRatio { 46 | width: number 47 | height: number 48 | [k: string]: unknown 49 | } 50 | 51 | export function isAspectRatio(v: unknown): v is AspectRatio { 52 | return ( 53 | isObj(v) && 54 | hasProp(v, '$type') && 55 | v.$type === 'app.bsky.embed.images#aspectRatio' 56 | ) 57 | } 58 | 59 | export function validateAspectRatio(v: unknown): ValidationResult { 60 | return lexicons.validate('app.bsky.embed.images#aspectRatio', v) 61 | } 62 | 63 | export interface View { 64 | images: ViewImage[] 65 | [k: string]: unknown 66 | } 67 | 68 | export function isView(v: unknown): v is View { 69 | return ( 70 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#view' 71 | ) 72 | } 73 | 74 | export function validateView(v: unknown): ValidationResult { 75 | return lexicons.validate('app.bsky.embed.images#view', v) 76 | } 77 | 78 | export interface ViewImage { 79 | thumb: string 80 | fullsize: string 81 | alt: string 82 | aspectRatio?: AspectRatio 83 | [k: string]: unknown 84 | } 85 | 86 | export function isViewImage(v: unknown): v is ViewImage { 87 | return ( 88 | isObj(v) && 89 | hasProp(v, '$type') && 90 | v.$type === 'app.bsky.embed.images#viewImage' 91 | ) 92 | } 93 | 94 | export function validateViewImage(v: unknown): ValidationResult { 95 | return lexicons.validate('app.bsky.embed.images#viewImage', v) 96 | } 97 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | # intellij 133 | .idea/ 134 | *.iml 135 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/richtext/facet.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | 9 | export interface Main { 10 | index: ByteSlice 11 | features: (Mention | Link | Tag | { $type: string; [k: string]: unknown })[] 12 | [k: string]: unknown 13 | } 14 | 15 | export function isMain(v: unknown): v is Main { 16 | return ( 17 | isObj(v) && 18 | hasProp(v, '$type') && 19 | (v.$type === 'app.bsky.richtext.facet#main' || 20 | v.$type === 'app.bsky.richtext.facet') 21 | ) 22 | } 23 | 24 | export function validateMain(v: unknown): ValidationResult { 25 | return lexicons.validate('app.bsky.richtext.facet#main', v) 26 | } 27 | 28 | /** A facet feature for actor mentions. */ 29 | export interface Mention { 30 | did: string 31 | [k: string]: unknown 32 | } 33 | 34 | export function isMention(v: unknown): v is Mention { 35 | return ( 36 | isObj(v) && 37 | hasProp(v, '$type') && 38 | v.$type === 'app.bsky.richtext.facet#mention' 39 | ) 40 | } 41 | 42 | export function validateMention(v: unknown): ValidationResult { 43 | return lexicons.validate('app.bsky.richtext.facet#mention', v) 44 | } 45 | 46 | /** A facet feature for links. */ 47 | export interface Link { 48 | uri: string 49 | [k: string]: unknown 50 | } 51 | 52 | export function isLink(v: unknown): v is Link { 53 | return ( 54 | isObj(v) && 55 | hasProp(v, '$type') && 56 | v.$type === 'app.bsky.richtext.facet#link' 57 | ) 58 | } 59 | 60 | export function validateLink(v: unknown): ValidationResult { 61 | return lexicons.validate('app.bsky.richtext.facet#link', v) 62 | } 63 | 64 | /** A hashtag. */ 65 | export interface Tag { 66 | tag: string 67 | [k: string]: unknown 68 | } 69 | 70 | export function isTag(v: unknown): v is Tag { 71 | return ( 72 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#tag' 73 | ) 74 | } 75 | 76 | export function validateTag(v: unknown): ValidationResult { 77 | return lexicons.validate('app.bsky.richtext.facet#tag', v) 78 | } 79 | 80 | /** A text segment. Start is inclusive, end is exclusive. Indices are for utf8-encoded strings. */ 81 | export interface ByteSlice { 82 | byteStart: number 83 | byteEnd: number 84 | [k: string]: unknown 85 | } 86 | 87 | export function isByteSlice(v: unknown): v is ByteSlice { 88 | return ( 89 | isObj(v) && 90 | hasProp(v, '$type') && 91 | v.$type === 'app.bsky.richtext.facet#byteSlice' 92 | ) 93 | } 94 | 95 | export function validateByteSlice(v: unknown): ValidationResult { 96 | return lexicons.validate('app.bsky.richtext.facet#byteSlice', v) 97 | } 98 | -------------------------------------------------------------------------------- /src/lexicon/types/com/atproto/repo/applyWrites.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import express from 'express' 5 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 6 | import { lexicons } from '../../../../lexicons' 7 | import { isObj, hasProp } from '../../../../util' 8 | import { CID } from 'multiformats/cid' 9 | import { HandlerAuth } from '@atproto/xrpc-server' 10 | 11 | export interface QueryParams {} 12 | 13 | export interface InputSchema { 14 | /** The handle or DID of the repo. */ 15 | repo: string 16 | /** Validate the records? */ 17 | validate: boolean 18 | writes: (Create | Update | Delete)[] 19 | swapCommit?: string 20 | [k: string]: unknown 21 | } 22 | 23 | export interface HandlerInput { 24 | encoding: 'application/json' 25 | body: InputSchema 26 | } 27 | 28 | export interface HandlerError { 29 | status: number 30 | message?: string 31 | error?: 'InvalidSwap' 32 | } 33 | 34 | export type HandlerOutput = HandlerError | void 35 | export type HandlerReqCtx = { 36 | auth: HA 37 | params: QueryParams 38 | input: HandlerInput 39 | req: express.Request 40 | res: express.Response 41 | } 42 | export type Handler = ( 43 | ctx: HandlerReqCtx, 44 | ) => Promise | HandlerOutput 45 | 46 | /** Create a new record. */ 47 | export interface Create { 48 | collection: string 49 | rkey?: string 50 | value: {} 51 | [k: string]: unknown 52 | } 53 | 54 | export function isCreate(v: unknown): v is Create { 55 | return ( 56 | isObj(v) && 57 | hasProp(v, '$type') && 58 | v.$type === 'com.atproto.repo.applyWrites#create' 59 | ) 60 | } 61 | 62 | export function validateCreate(v: unknown): ValidationResult { 63 | return lexicons.validate('com.atproto.repo.applyWrites#create', v) 64 | } 65 | 66 | /** Update an existing record. */ 67 | export interface Update { 68 | collection: string 69 | rkey: string 70 | value: {} 71 | [k: string]: unknown 72 | } 73 | 74 | export function isUpdate(v: unknown): v is Update { 75 | return ( 76 | isObj(v) && 77 | hasProp(v, '$type') && 78 | v.$type === 'com.atproto.repo.applyWrites#update' 79 | ) 80 | } 81 | 82 | export function validateUpdate(v: unknown): ValidationResult { 83 | return lexicons.validate('com.atproto.repo.applyWrites#update', v) 84 | } 85 | 86 | /** Delete an existing record. */ 87 | export interface Delete { 88 | collection: string 89 | rkey: string 90 | [k: string]: unknown 91 | } 92 | 93 | export function isDelete(v: unknown): v is Delete { 94 | return ( 95 | isObj(v) && 96 | hasProp(v, '$type') && 97 | v.$type === 'com.atproto.repo.applyWrites#delete' 98 | ) 99 | } 100 | 101 | export function validateDelete(v: unknown): ValidationResult { 102 | return lexicons.validate('com.atproto.repo.applyWrites#delete', v) 103 | } 104 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/graph/defs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as AppBskyActorDefs from '../actor/defs' 9 | import * as AppBskyRichtextFacet from '../richtext/facet' 10 | 11 | export interface ListViewBasic { 12 | uri: string 13 | cid: string 14 | name: string 15 | purpose: ListPurpose 16 | avatar?: string 17 | viewer?: ListViewerState 18 | indexedAt?: string 19 | [k: string]: unknown 20 | } 21 | 22 | export function isListViewBasic(v: unknown): v is ListViewBasic { 23 | return ( 24 | isObj(v) && 25 | hasProp(v, '$type') && 26 | v.$type === 'app.bsky.graph.defs#listViewBasic' 27 | ) 28 | } 29 | 30 | export function validateListViewBasic(v: unknown): ValidationResult { 31 | return lexicons.validate('app.bsky.graph.defs#listViewBasic', v) 32 | } 33 | 34 | export interface ListView { 35 | uri: string 36 | cid: string 37 | creator: AppBskyActorDefs.ProfileView 38 | name: string 39 | purpose: ListPurpose 40 | description?: string 41 | descriptionFacets?: AppBskyRichtextFacet.Main[] 42 | avatar?: string 43 | viewer?: ListViewerState 44 | indexedAt: string 45 | [k: string]: unknown 46 | } 47 | 48 | export function isListView(v: unknown): v is ListView { 49 | return ( 50 | isObj(v) && 51 | hasProp(v, '$type') && 52 | v.$type === 'app.bsky.graph.defs#listView' 53 | ) 54 | } 55 | 56 | export function validateListView(v: unknown): ValidationResult { 57 | return lexicons.validate('app.bsky.graph.defs#listView', v) 58 | } 59 | 60 | export interface ListItemView { 61 | subject: AppBskyActorDefs.ProfileView 62 | [k: string]: unknown 63 | } 64 | 65 | export function isListItemView(v: unknown): v is ListItemView { 66 | return ( 67 | isObj(v) && 68 | hasProp(v, '$type') && 69 | v.$type === 'app.bsky.graph.defs#listItemView' 70 | ) 71 | } 72 | 73 | export function validateListItemView(v: unknown): ValidationResult { 74 | return lexicons.validate('app.bsky.graph.defs#listItemView', v) 75 | } 76 | 77 | export type ListPurpose = 78 | | 'app.bsky.graph.defs#modlist' 79 | | 'app.bsky.graph.defs#curatelist' 80 | | (string & {}) 81 | 82 | /** A list of actors to apply an aggregate moderation action (mute/block) on */ 83 | export const MODLIST = 'app.bsky.graph.defs#modlist' 84 | /** A list of actors used for curation purposes such as list feeds or interaction gating */ 85 | export const CURATELIST = 'app.bsky.graph.defs#curatelist' 86 | 87 | export interface ListViewerState { 88 | muted?: boolean 89 | blocked?: string 90 | [k: string]: unknown 91 | } 92 | 93 | export function isListViewerState(v: unknown): v is ListViewerState { 94 | return ( 95 | isObj(v) && 96 | hasProp(v, '$type') && 97 | v.$type === 'app.bsky.graph.defs#listViewerState' 98 | ) 99 | } 100 | 101 | export function validateListViewerState(v: unknown): ValidationResult { 102 | return lexicons.validate('app.bsky.graph.defs#listViewerState', v) 103 | } 104 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/feed/post.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as AppBskyRichtextFacet from '../richtext/facet' 9 | import * as AppBskyEmbedImages from '../embed/images' 10 | import * as AppBskyEmbedExternal from '../embed/external' 11 | import * as AppBskyEmbedRecord from '../embed/record' 12 | import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' 13 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 14 | import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' 15 | 16 | export interface Record { 17 | text: string 18 | /** Deprecated: replaced by app.bsky.richtext.facet. */ 19 | entities?: Entity[] 20 | facets?: AppBskyRichtextFacet.Main[] 21 | reply?: ReplyRef 22 | embed?: 23 | | AppBskyEmbedImages.Main 24 | | AppBskyEmbedExternal.Main 25 | | AppBskyEmbedRecord.Main 26 | | AppBskyEmbedRecordWithMedia.Main 27 | | { $type: string; [k: string]: unknown } 28 | langs?: string[] 29 | labels?: 30 | | ComAtprotoLabelDefs.SelfLabels 31 | | { $type: string; [k: string]: unknown } 32 | /** Additional non-inline tags describing this post. */ 33 | tags?: string[] 34 | createdAt: string 35 | [k: string]: unknown 36 | } 37 | 38 | export function isRecord(v: unknown): v is Record { 39 | return ( 40 | isObj(v) && 41 | hasProp(v, '$type') && 42 | (v.$type === 'app.bsky.feed.post#main' || v.$type === 'app.bsky.feed.post') 43 | ) 44 | } 45 | 46 | export function validateRecord(v: unknown): ValidationResult { 47 | return lexicons.validate('app.bsky.feed.post#main', v) 48 | } 49 | 50 | export interface ReplyRef { 51 | root: ComAtprotoRepoStrongRef.Main 52 | parent: ComAtprotoRepoStrongRef.Main 53 | [k: string]: unknown 54 | } 55 | 56 | export function isReplyRef(v: unknown): v is ReplyRef { 57 | return ( 58 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#replyRef' 59 | ) 60 | } 61 | 62 | export function validateReplyRef(v: unknown): ValidationResult { 63 | return lexicons.validate('app.bsky.feed.post#replyRef', v) 64 | } 65 | 66 | /** Deprecated: use facets instead. */ 67 | export interface Entity { 68 | index: TextSlice 69 | /** Expected values are 'mention' and 'link'. */ 70 | type: string 71 | value: string 72 | [k: string]: unknown 73 | } 74 | 75 | export function isEntity(v: unknown): v is Entity { 76 | return ( 77 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#entity' 78 | ) 79 | } 80 | 81 | export function validateEntity(v: unknown): ValidationResult { 82 | return lexicons.validate('app.bsky.feed.post#entity', v) 83 | } 84 | 85 | /** Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings. */ 86 | export interface TextSlice { 87 | start: number 88 | end: number 89 | [k: string]: unknown 90 | } 91 | 92 | export function isTextSlice(v: unknown): v is TextSlice { 93 | return ( 94 | isObj(v) && 95 | hasProp(v, '$type') && 96 | v.$type === 'app.bsky.feed.post#textSlice' 97 | ) 98 | } 99 | 100 | export function validateTextSlice(v: unknown): ValidationResult { 101 | return lexicons.validate('app.bsky.feed.post#textSlice', v) 102 | } 103 | -------------------------------------------------------------------------------- /src/lexicon/types/app/bsky/embed/record.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GENERATED CODE - DO NOT MODIFY 3 | */ 4 | import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 | import { lexicons } from '../../../../lexicons' 6 | import { isObj, hasProp } from '../../../../util' 7 | import { CID } from 'multiformats/cid' 8 | import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' 9 | import * as AppBskyFeedDefs from '../feed/defs' 10 | import * as AppBskyGraphDefs from '../graph/defs' 11 | import * as AppBskyActorDefs from '../actor/defs' 12 | import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' 13 | import * as AppBskyEmbedImages from './images' 14 | import * as AppBskyEmbedExternal from './external' 15 | import * as AppBskyEmbedRecordWithMedia from './recordWithMedia' 16 | 17 | export interface Main { 18 | record: ComAtprotoRepoStrongRef.Main 19 | [k: string]: unknown 20 | } 21 | 22 | export function isMain(v: unknown): v is Main { 23 | return ( 24 | isObj(v) && 25 | hasProp(v, '$type') && 26 | (v.$type === 'app.bsky.embed.record#main' || 27 | v.$type === 'app.bsky.embed.record') 28 | ) 29 | } 30 | 31 | export function validateMain(v: unknown): ValidationResult { 32 | return lexicons.validate('app.bsky.embed.record#main', v) 33 | } 34 | 35 | export interface View { 36 | record: 37 | | ViewRecord 38 | | ViewNotFound 39 | | ViewBlocked 40 | | AppBskyFeedDefs.GeneratorView 41 | | AppBskyGraphDefs.ListView 42 | | { $type: string; [k: string]: unknown } 43 | [k: string]: unknown 44 | } 45 | 46 | export function isView(v: unknown): v is View { 47 | return ( 48 | isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.record#view' 49 | ) 50 | } 51 | 52 | export function validateView(v: unknown): ValidationResult { 53 | return lexicons.validate('app.bsky.embed.record#view', v) 54 | } 55 | 56 | export interface ViewRecord { 57 | uri: string 58 | cid: string 59 | author: AppBskyActorDefs.ProfileViewBasic 60 | value: {} 61 | labels?: ComAtprotoLabelDefs.Label[] 62 | embeds?: ( 63 | | AppBskyEmbedImages.View 64 | | AppBskyEmbedExternal.View 65 | | View 66 | | AppBskyEmbedRecordWithMedia.View 67 | | { $type: string; [k: string]: unknown } 68 | )[] 69 | indexedAt: string 70 | [k: string]: unknown 71 | } 72 | 73 | export function isViewRecord(v: unknown): v is ViewRecord { 74 | return ( 75 | isObj(v) && 76 | hasProp(v, '$type') && 77 | v.$type === 'app.bsky.embed.record#viewRecord' 78 | ) 79 | } 80 | 81 | export function validateViewRecord(v: unknown): ValidationResult { 82 | return lexicons.validate('app.bsky.embed.record#viewRecord', v) 83 | } 84 | 85 | export interface ViewNotFound { 86 | uri: string 87 | notFound: true 88 | [k: string]: unknown 89 | } 90 | 91 | export function isViewNotFound(v: unknown): v is ViewNotFound { 92 | return ( 93 | isObj(v) && 94 | hasProp(v, '$type') && 95 | v.$type === 'app.bsky.embed.record#viewNotFound' 96 | ) 97 | } 98 | 99 | export function validateViewNotFound(v: unknown): ValidationResult { 100 | return lexicons.validate('app.bsky.embed.record#viewNotFound', v) 101 | } 102 | 103 | export interface ViewBlocked { 104 | uri: string 105 | blocked: true 106 | author: AppBskyFeedDefs.BlockedAuthor 107 | [k: string]: unknown 108 | } 109 | 110 | export function isViewBlocked(v: unknown): v is ViewBlocked { 111 | return ( 112 | isObj(v) && 113 | hasProp(v, '$type') && 114 | v.$type === 'app.bsky.embed.record#viewBlocked' 115 | ) 116 | } 117 | 118 | export function validateViewBlocked(v: unknown): ValidationResult { 119 | return lexicons.validate('app.bsky.embed.record#viewBlocked', v) 120 | } 121 | -------------------------------------------------------------------------------- /scripts/publishFeedGen.ts: -------------------------------------------------------------------------------- 1 | import dotenv from 'dotenv' 2 | import inquirer from 'inquirer' 3 | import { AtpAgent, BlobRef, AppBskyFeedDefs } from '@atproto/api' 4 | import fs from 'fs/promises' 5 | import { ids } from '../src/lexicon/lexicons' 6 | 7 | const run = async () => { 8 | dotenv.config() 9 | 10 | if (!process.env.FEEDGEN_SERVICE_DID && !process.env.FEEDGEN_HOSTNAME) { 11 | throw new Error('Please provide a hostname in the .env file') 12 | } 13 | 14 | const answers = await inquirer 15 | .prompt([ 16 | { 17 | type: 'input', 18 | name: 'handle', 19 | message: 'Enter your Bluesky handle:', 20 | required: true, 21 | }, 22 | { 23 | type: 'password', 24 | name: 'password', 25 | message: 'Enter your Bluesky password (preferably an App Password):', 26 | }, 27 | { 28 | type: 'input', 29 | name: 'service', 30 | message: 'Optionally, enter a custom PDS service to sign in with:', 31 | default: 'https://bsky.social', 32 | required: false, 33 | }, 34 | { 35 | type: 'input', 36 | name: 'recordName', 37 | message: 'Enter a short name or the record. This will be shown in the feed\'s URL:', 38 | required: true, 39 | }, 40 | { 41 | type: 'input', 42 | name: 'displayName', 43 | message: 'Enter a display name for your feed:', 44 | required: true, 45 | }, 46 | { 47 | type: 'input', 48 | name: 'description', 49 | message: 'Optionally, enter a brief description of your feed:', 50 | required: false, 51 | }, 52 | { 53 | type: 'input', 54 | name: 'avatar', 55 | message: 'Optionally, enter a local path to an avatar that will be used for the feed:', 56 | required: false, 57 | }, 58 | { 59 | type: 'confirm', 60 | name: 'videoOnly', 61 | message: 'Is this a video-only feed? If so, do you want to set the content mode to video? This will allow for an "immersive" video experience within the app.', 62 | default: false, 63 | } 64 | ]) 65 | 66 | const { handle, password, recordName, displayName, description, avatar, service, videoOnly } = answers 67 | 68 | const feedGenDid = 69 | process.env.FEEDGEN_SERVICE_DID ?? `did:web:${process.env.FEEDGEN_HOSTNAME}` 70 | 71 | // only update this if in a test environment 72 | const agent = new AtpAgent({ service: service ? service : 'https://bsky.social' }) 73 | await agent.login({ identifier: handle, password}) 74 | 75 | let avatarRef: BlobRef | undefined 76 | if (avatar) { 77 | let encoding: string 78 | if (avatar.endsWith('png')) { 79 | encoding = 'image/png' 80 | } else if (avatar.endsWith('jpg') || avatar.endsWith('jpeg')) { 81 | encoding = 'image/jpeg' 82 | } else { 83 | throw new Error('expected png or jpeg') 84 | } 85 | const img = await fs.readFile(avatar) 86 | const blobRes = await agent.api.com.atproto.repo.uploadBlob(img, { 87 | encoding, 88 | }) 89 | avatarRef = blobRes.data.blob 90 | } 91 | 92 | await agent.api.com.atproto.repo.putRecord({ 93 | repo: agent.session?.did ?? '', 94 | collection: ids.AppBskyFeedGenerator, 95 | rkey: recordName, 96 | record: { 97 | did: feedGenDid, 98 | displayName: displayName, 99 | description: description, 100 | avatar: avatarRef, 101 | createdAt: new Date().toISOString(), 102 | contentMode: videoOnly ? AppBskyFeedDefs.CONTENTMODEVIDEO : AppBskyFeedDefs.CONTENTMODEUNSPECIFIED, 103 | }, 104 | }) 105 | 106 | console.log('All done 🎉') 107 | } 108 | 109 | run() 110 | --------------------------------------------------------------------------------