An experimental TypeSpec syntax for Lexicon
56
fork

Configure Feed

Select the types of activity you want to include in your feed.

at cli 223 lines 5.5 kB view raw
1/** 2 * GENERATED CODE - DO NOT MODIFY 3 */ 4import { 5 type LexiconDoc, 6 Lexicons, 7 ValidationError, 8 type ValidationResult, 9} from '@atproto/lexicon' 10import { type $Typed, is$typed, maybe$typed } from './util.js' 11 12export const schemaDict = { 13 XyzStatusphereDefs: { 14 lexicon: 1, 15 id: 'xyz.statusphere.defs', 16 defs: { 17 statusView: { 18 type: 'object', 19 properties: { 20 uri: { 21 type: 'string', 22 format: 'at-uri', 23 }, 24 status: { 25 type: 'string', 26 maxLength: 32, 27 minLength: 1, 28 maxGraphemes: 1, 29 }, 30 createdAt: { 31 type: 'string', 32 format: 'datetime', 33 }, 34 profile: { 35 type: 'ref', 36 ref: 'lex:xyz.statusphere.defs#profileView', 37 }, 38 }, 39 required: ['uri', 'status', 'createdAt', 'profile'], 40 }, 41 profileView: { 42 type: 'object', 43 properties: { 44 did: { 45 type: 'string', 46 format: 'did', 47 }, 48 handle: { 49 type: 'string', 50 format: 'handle', 51 }, 52 }, 53 required: ['did', 'handle'], 54 }, 55 }, 56 }, 57 XyzStatusphereGetStatuses: { 58 lexicon: 1, 59 id: 'xyz.statusphere.getStatuses', 60 defs: { 61 main: { 62 type: 'query', 63 description: 'Get a list of the most recent statuses on the network.', 64 parameters: { 65 type: 'params', 66 properties: { 67 limit: { 68 type: 'integer', 69 minimum: 1, 70 maximum: 100, 71 default: 50, 72 }, 73 }, 74 }, 75 output: { 76 encoding: 'application/json', 77 schema: { 78 type: 'object', 79 properties: { 80 statuses: { 81 type: 'array', 82 items: { 83 type: 'ref', 84 ref: 'lex:xyz.statusphere.defs#statusView', 85 }, 86 }, 87 }, 88 required: ['statuses'], 89 }, 90 }, 91 }, 92 }, 93 }, 94 XyzStatusphereGetUser: { 95 lexicon: 1, 96 id: 'xyz.statusphere.getUser', 97 defs: { 98 main: { 99 type: 'query', 100 description: "Get the current user's profile and status.", 101 output: { 102 encoding: 'application/json', 103 schema: { 104 type: 'object', 105 properties: { 106 profile: { 107 type: 'ref', 108 ref: 'lex:app.bsky.actor.defs#profileView', 109 }, 110 status: { 111 type: 'ref', 112 ref: 'lex:xyz.statusphere.defs#statusView', 113 }, 114 }, 115 required: ['profile'], 116 }, 117 }, 118 }, 119 }, 120 }, 121 XyzStatusphereSendStatus: { 122 lexicon: 1, 123 id: 'xyz.statusphere.sendStatus', 124 defs: { 125 main: { 126 type: 'procedure', 127 description: 'Send a status into the ATmosphere.', 128 input: { 129 encoding: 'application/json', 130 schema: { 131 type: 'object', 132 properties: { 133 status: { 134 type: 'string', 135 maxLength: 32, 136 minLength: 1, 137 maxGraphemes: 1, 138 }, 139 }, 140 required: ['status'], 141 }, 142 }, 143 output: { 144 encoding: 'application/json', 145 schema: { 146 type: 'object', 147 properties: { 148 status: { 149 type: 'ref', 150 ref: 'lex:xyz.statusphere.defs#statusView', 151 }, 152 }, 153 required: ['status'], 154 }, 155 }, 156 }, 157 }, 158 }, 159 XyzStatusphereStatus: { 160 lexicon: 1, 161 id: 'xyz.statusphere.status', 162 defs: { 163 main: { 164 type: 'record', 165 key: 'tid', 166 record: { 167 type: 'object', 168 properties: { 169 status: { 170 type: 'string', 171 maxLength: 32, 172 minLength: 1, 173 maxGraphemes: 1, 174 }, 175 createdAt: { 176 type: 'string', 177 format: 'datetime', 178 }, 179 }, 180 required: ['status', 'createdAt'], 181 }, 182 }, 183 }, 184 }, 185} as const satisfies Record<string, LexiconDoc> 186export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] 187export const lexicons: Lexicons = new Lexicons(schemas) 188 189export function validate<T extends { $type: string }>( 190 v: unknown, 191 id: string, 192 hash: string, 193 requiredType: true, 194): ValidationResult<T> 195export function validate<T extends { $type?: string }>( 196 v: unknown, 197 id: string, 198 hash: string, 199 requiredType?: false, 200): ValidationResult<T> 201export function validate( 202 v: unknown, 203 id: string, 204 hash: string, 205 requiredType?: boolean, 206): ValidationResult { 207 return (requiredType ? is$typed : maybe$typed)(v, id, hash) 208 ? lexicons.validate(`${id}#${hash}`, v) 209 : { 210 success: false, 211 error: new ValidationError( 212 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 213 ), 214 } 215} 216 217export const ids = { 218 XyzStatusphereDefs: 'xyz.statusphere.defs', 219 XyzStatusphereGetStatuses: 'xyz.statusphere.getStatuses', 220 XyzStatusphereGetUser: 'xyz.statusphere.getUser', 221 XyzStatusphereSendStatus: 'xyz.statusphere.sendStatus', 222 XyzStatusphereStatus: 'xyz.statusphere.status', 223} as const