the statusphere demo reworked into a vite/react app in a monorepo

Change status lexicon to xyz.statusphere.status

+21 -20
+1 -1
lexicons/status.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "com.example.status", 3 + "id": "xyz.statusphere.status", 4 4 "defs": { 5 5 "main": { 6 6 "type": "record",
+4 -4
src/ingester.ts
··· 2 2 import { IdResolver } from '@atproto/identity' 3 3 import { Firehose } from '@atproto/sync' 4 4 import type { Database } from '#/db' 5 - import * as Status from '#/lexicon/types/com/example/status' 5 + import * as Status from '#/lexicon/types/xyz/statusphere/status' 6 6 7 7 export function createIngester(db: Database, idResolver: IdResolver) { 8 8 const logger = pino({ name: 'firehose ingestion' }) ··· 15 15 16 16 // If the write is a valid status update 17 17 if ( 18 - evt.collection === 'com.example.status' && 18 + evt.collection === 'xyz.statusphere.status' && 19 19 Status.isRecord(record) && 20 20 Status.validateRecord(record).success 21 21 ) { ··· 39 39 } 40 40 } else if ( 41 41 evt.event === 'delete' && 42 - evt.collection === 'com.example.status' 42 + evt.collection === 'xyz.statusphere.status' 43 43 ) { 44 44 // Remove the status from our SQLite 45 45 await db.deleteFrom('status').where({ uri: evt.uri.toString() }) ··· 48 48 onError: (err) => { 49 49 logger.error({ err }, 'error on firehose ingestion') 50 50 }, 51 - filterCollections: ['com.example.status'], 51 + filterCollections: ['xyz.statusphere.status'], 52 52 excludeIdentity: true, 53 53 excludeAccount: true, 54 54 })
+6 -6
src/lexicon/index.ts
··· 17 17 export class Server { 18 18 xrpc: XrpcServer 19 19 app: AppNS 20 - com: ComNS 20 + xyz: XyzNS 21 21 22 22 constructor(options?: XrpcOptions) { 23 23 this.xrpc = createXrpcServer(schemas, options) 24 24 this.app = new AppNS(this) 25 - this.com = new ComNS(this) 25 + this.xyz = new XyzNS(this) 26 26 } 27 27 } 28 28 ··· 54 54 } 55 55 } 56 56 57 - export class ComNS { 57 + export class XyzNS { 58 58 _server: Server 59 - example: ComExampleNS 59 + statusphere: XyzStatusphereNS 60 60 61 61 constructor(server: Server) { 62 62 this._server = server 63 - this.example = new ComExampleNS(server) 63 + this.statusphere = new XyzStatusphereNS(server) 64 64 } 65 65 } 66 66 67 - export class ComExampleNS { 67 + export class XyzStatusphereNS { 68 68 _server: Server 69 69 70 70 constructor(server: Server) {
+4 -4
src/lexicon/lexicons.ts
··· 59 59 }, 60 60 }, 61 61 }, 62 - ComExampleStatus: { 62 + XyzStatusphereStatus: { 63 63 lexicon: 1, 64 - id: 'com.example.status', 64 + id: 'xyz.statusphere.status', 65 65 defs: { 66 66 main: { 67 67 type: 'record', 68 - key: 'literal:self', 68 + key: 'tid', 69 69 record: { 70 70 type: 'object', 71 71 required: ['status', 'createdAt'], ··· 90 90 export const lexicons: Lexicons = new Lexicons(schemas) 91 91 export const ids = { 92 92 AppBskyActorProfile: 'app.bsky.actor.profile', 93 - ComExampleStatus: 'com.example.status', 93 + XyzStatusphereStatus: 'xyz.statusphere.status', 94 94 }
+3 -2
src/lexicon/types/com/example/status.ts src/lexicon/types/xyz/statusphere/status.ts
··· 16 16 return ( 17 17 isObj(v) && 18 18 hasProp(v, '$type') && 19 - (v.$type === 'com.example.status#main' || v.$type === 'com.example.status') 19 + (v.$type === 'xyz.statusphere.status#main' || 20 + v.$type === 'xyz.statusphere.status') 20 21 ) 21 22 } 22 23 23 24 export function validateRecord(v: unknown): ValidationResult { 24 - return lexicons.validate('com.example.status#main', v) 25 + return lexicons.validate('xyz.statusphere.status#main', v) 25 26 }
+3 -3
src/routes.ts
··· 12 12 import { login } from '#/pages/login' 13 13 import { env } from '#/lib/env' 14 14 import { page } from '#/lib/view' 15 - import * as Status from '#/lexicon/types/com/example/status' 15 + import * as Status from '#/lexicon/types/xyz/statusphere/status' 16 16 import * as Profile from '#/lexicon/types/app/bsky/actor/profile' 17 17 18 18 type Session = { did: string } ··· 217 217 // Construct & validate their status record 218 218 const rkey = TID.nextStr() 219 219 const record = { 220 - $type: 'com.example.status', 220 + $type: 'xyz.statusphere.status', 221 221 status: req.body?.status, 222 222 createdAt: new Date().toISOString(), 223 223 } ··· 233 233 // Write the status record to the user's repository 234 234 const res = await agent.com.atproto.repo.putRecord({ 235 235 repo: agent.assertDid, 236 - collection: 'com.example.status', 236 + collection: 'xyz.statusphere.status', 237 237 rkey, 238 238 record, 239 239 validate: false,