/** * GENERATED CODE - DO NOT MODIFY */ import { type LexiconDoc, Lexicons, ValidationError, type ValidationResult, } from '@atproto/lexicon' import { type $Typed, is$typed, maybe$typed } from './util.js' export const schemaDict = { AppExampleDefs: { lexicon: 1, id: 'app.example.defs', defs: { postRef: { type: 'object', properties: { uri: { type: 'string', description: 'AT URI of the post', }, cid: { type: 'string', description: 'CID of the post', }, }, description: 'Reference to a post', required: ['uri', 'cid'], }, replyRef: { type: 'object', properties: { root: { type: 'ref', ref: 'lex:app.example.defs#postRef', description: 'Root post in the thread', }, parent: { type: 'ref', ref: 'lex:app.example.defs#postRef', description: 'Direct parent post being replied to', }, }, description: 'Reference to a parent post in a reply chain', required: ['root', 'parent'], }, entity: { type: 'object', properties: { start: { type: 'integer', description: 'Start index in text', }, end: { type: 'integer', description: 'End index in text', }, type: { type: 'string', description: 'Entity type', }, value: { type: 'string', description: 'Entity value (handle, URL, or tag)', }, }, description: 'Text entity (mention, link, or tag)', required: ['start', 'end', 'type', 'value'], }, notificationType: { type: 'string', knownValues: ['like', 'repost', 'follow', 'mention', 'reply'], description: 'Type of notification', }, }, }, AppExampleFollow: { lexicon: 1, id: 'app.example.follow', defs: { main: { type: 'record', key: 'tid', record: { type: 'object', properties: { subject: { type: 'string', description: 'DID of the account being followed', }, createdAt: { type: 'string', format: 'datetime', description: 'When the follow was created', }, }, required: ['subject', 'createdAt'], }, description: 'A follow relationship', }, }, }, AppExampleLike: { lexicon: 1, id: 'app.example.like', defs: { main: { type: 'record', key: 'tid', record: { type: 'object', properties: { subject: { type: 'ref', ref: 'lex:app.example.defs#postRef', description: 'Post being liked', }, createdAt: { type: 'string', format: 'datetime', description: 'When the like was created', }, }, required: ['subject', 'createdAt'], }, description: 'A like on a post', }, }, }, AppExamplePost: { lexicon: 1, id: 'app.example.post', defs: { main: { type: 'record', key: 'tid', record: { type: 'object', properties: { text: { type: 'string', description: 'Post text content', }, createdAt: { type: 'string', format: 'datetime', description: 'Creation timestamp', }, langs: { type: 'array', items: { type: 'string', }, description: 'Languages the post is written in', }, entities: { type: 'array', items: { type: 'ref', ref: 'lex:app.example.defs#entity', }, description: 'Referenced entities in the post', }, reply: { type: 'ref', ref: 'lex:app.example.defs#replyRef', description: 'Post the user is replying to', }, }, required: ['text', 'createdAt'], }, description: 'A post in the feed', }, }, }, AppExampleProfile: { lexicon: 1, id: 'app.example.profile', defs: { main: { type: 'record', key: 'self', record: { type: 'object', properties: { displayName: { type: 'string', description: 'Display name', }, description: { type: 'string', description: 'Profile description', }, avatar: { type: 'string', description: 'Profile avatar image', }, banner: { type: 'string', description: 'Profile banner image', }, }, }, description: 'User profile information', }, }, }, AppExampleRepost: { lexicon: 1, id: 'app.example.repost', defs: { main: { type: 'record', key: 'tid', record: { type: 'object', properties: { subject: { type: 'ref', ref: 'lex:app.example.defs#postRef', description: 'Post being reposted', }, createdAt: { type: 'string', format: 'datetime', description: 'When the repost was created', }, }, required: ['subject', 'createdAt'], }, description: 'A repost of another post', }, }, }, } as const satisfies Record export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] export const lexicons: Lexicons = new Lexicons(schemas) export function validate( v: unknown, id: string, hash: string, requiredType: true, ): ValidationResult export function validate( v: unknown, id: string, hash: string, requiredType?: false, ): ValidationResult export function validate( v: unknown, id: string, hash: string, requiredType?: boolean, ): ValidationResult { return (requiredType ? is$typed : maybe$typed)(v, id, hash) ? lexicons.validate(`${id}#${hash}`, v) : { success: false, error: new ValidationError( `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, ), } } export const ids = { AppExampleDefs: 'app.example.defs', AppExampleFollow: 'app.example.follow', AppExampleLike: 'app.example.like', AppExamplePost: 'app.example.post', AppExampleProfile: 'app.example.profile', AppExampleRepost: 'app.example.repost', } as const