This repository has no description
0

Configure Feed

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

semble / src / modules / atproto / infrastructure / lexicon / lexicons.ts
9.7 kB 327 lines
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 NetworkCosmikCard: { 14 lexicon: 1, 15 id: 'network.cosmik.card', 16 description: 'A single record type for all cards.', 17 defs: { 18 main: { 19 type: 'record', 20 description: 'A record representing a card with content.', 21 key: 'tid', 22 record: { 23 type: 'object', 24 required: ['type', 'content'], 25 properties: { 26 type: { 27 type: 'string', 28 description: 'The type of card', 29 knownValues: ['URL', 'NOTE'], 30 }, 31 content: { 32 type: 'union', 33 description: 34 'The specific content of the card, determined by the card type.', 35 refs: [ 36 'lex:network.cosmik.card#urlContent', 37 'lex:network.cosmik.card#noteContent', 38 ], 39 }, 40 url: { 41 type: 'string', 42 format: 'uri', 43 description: 44 'Optional URL associated with the card. Required for URL cards, optional for NOTE cards.', 45 }, 46 parentCard: { 47 type: 'ref', 48 description: 49 'Optional strong reference to a parent card (for NOTE cards).', 50 ref: 'lex:com.atproto.repo.strongRef', 51 }, 52 createdAt: { 53 type: 'string', 54 format: 'datetime', 55 description: 56 'Timestamp when this card was created (usually set by PDS).', 57 }, 58 originalCard: { 59 type: 'ref', 60 description: 61 'Optional strong reference to the original card (for NOTE cards).', 62 ref: 'lex:com.atproto.repo.strongRef', 63 }, 64 }, 65 }, 66 }, 67 urlContent: { 68 type: 'object', 69 description: 'Content structure for a URL card.', 70 required: ['url'], 71 properties: { 72 url: { 73 type: 'string', 74 format: 'uri', 75 description: 'The URL being saved', 76 }, 77 metadata: { 78 type: 'ref', 79 ref: 'lex:network.cosmik.card#urlMetadata', 80 description: 'Optional metadata about the URL', 81 }, 82 }, 83 }, 84 noteContent: { 85 type: 'object', 86 description: 'Content structure for a note card.', 87 required: ['text'], 88 properties: { 89 text: { 90 type: 'string', 91 description: 'The note text content', 92 maxLength: 10000, 93 }, 94 }, 95 }, 96 urlMetadata: { 97 type: 'object', 98 description: 'Metadata about a URL.', 99 properties: { 100 title: { 101 type: 'string', 102 description: 'Title of the page', 103 }, 104 description: { 105 type: 'string', 106 description: 'Description of the page', 107 }, 108 author: { 109 type: 'string', 110 description: 'Author of the content', 111 }, 112 publishedDate: { 113 type: 'string', 114 format: 'datetime', 115 description: 'When the content was published', 116 }, 117 siteName: { 118 type: 'string', 119 description: 'Name of the site', 120 }, 121 imageUrl: { 122 type: 'string', 123 format: 'uri', 124 description: 'URL of a representative image', 125 }, 126 type: { 127 type: 'string', 128 description: "Type of content (e.g., 'video', 'article')", 129 }, 130 retrievedAt: { 131 type: 'string', 132 format: 'datetime', 133 description: 'When the metadata was retrieved', 134 }, 135 }, 136 }, 137 }, 138 }, 139 NetworkCosmikCollection: { 140 lexicon: 1, 141 id: 'network.cosmik.collection', 142 description: 'A single record type for collections of cards.', 143 defs: { 144 main: { 145 type: 'record', 146 description: 'A record representing a collection of cards.', 147 key: 'tid', 148 record: { 149 type: 'object', 150 required: ['name', 'accessType'], 151 properties: { 152 name: { 153 type: 'string', 154 description: 'Name of the collection', 155 maxLength: 100, 156 }, 157 description: { 158 type: 'string', 159 description: 'Description of the collection', 160 maxLength: 500, 161 }, 162 accessType: { 163 type: 'string', 164 description: 'Access control for the collection', 165 knownValues: ['OPEN', 'CLOSED'], 166 }, 167 collaborators: { 168 type: 'array', 169 description: 170 'List of collaborator DIDs who can add cards to closed collections', 171 items: { 172 type: 'string', 173 description: 'DID of a collaborator', 174 }, 175 }, 176 createdAt: { 177 type: 'string', 178 format: 'datetime', 179 description: 180 'Timestamp when this collection was created (usually set by PDS).', 181 }, 182 updatedAt: { 183 type: 'string', 184 format: 'datetime', 185 description: 'Timestamp when this collection was last updated.', 186 }, 187 }, 188 }, 189 }, 190 }, 191 }, 192 NetworkCosmikCollectionLink: { 193 lexicon: 1, 194 id: 'network.cosmik.collectionLink', 195 description: 'A record that links a card to a collection.', 196 defs: { 197 main: { 198 type: 'record', 199 description: 200 'A record representing the relationship between a card and a collection.', 201 key: 'tid', 202 record: { 203 type: 'object', 204 required: ['collection', 'card', 'addedBy', 'addedAt'], 205 properties: { 206 collection: { 207 type: 'ref', 208 description: 'Strong reference to the collection record.', 209 ref: 'lex:com.atproto.repo.strongRef', 210 }, 211 card: { 212 type: 'ref', 213 description: 214 'Strong reference to the card record in the users library.', 215 ref: 'lex:com.atproto.repo.strongRef', 216 }, 217 originalCard: { 218 type: 'ref', 219 description: 220 'Strong reference to the original card record (may be in another library).', 221 ref: 'lex:com.atproto.repo.strongRef', 222 }, 223 addedBy: { 224 type: 'string', 225 description: 226 'DID of the user who added the card to the collection', 227 }, 228 addedAt: { 229 type: 'string', 230 format: 'datetime', 231 description: 232 'Timestamp when the card was added to the collection.', 233 }, 234 createdAt: { 235 type: 'string', 236 format: 'datetime', 237 description: 238 'Timestamp when this link record was created (usually set by PDS).', 239 }, 240 }, 241 }, 242 }, 243 }, 244 }, 245 NetworkCosmikDefs: { 246 lexicon: 1, 247 id: 'network.cosmik.defs', 248 description: 'Common definitions for annotation types and references', 249 defs: { 250 identifier: { 251 type: 'object', 252 description: 'Represents an identifier with a type and value.', 253 required: ['type', 'value'], 254 properties: { 255 type: { 256 type: 'string', 257 description: 258 "The type of identifier (e.g., 'doi', 'at-uri', 'isbn').", 259 }, 260 value: { 261 type: 'string', 262 description: 'The identifier value.', 263 }, 264 }, 265 }, 266 }, 267 }, 268 ComAtprotoRepoStrongRef: { 269 lexicon: 1, 270 id: 'com.atproto.repo.strongRef', 271 description: 'A URI with a content-hash fingerprint.', 272 defs: { 273 main: { 274 type: 'object', 275 required: ['uri', 'cid'], 276 properties: { 277 cid: { 278 type: 'string', 279 format: 'cid', 280 }, 281 uri: { 282 type: 'string', 283 format: 'at-uri', 284 }, 285 }, 286 }, 287 }, 288 }, 289} as const satisfies Record<string, LexiconDoc>; 290export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]; 291export const lexicons: Lexicons = new Lexicons(schemas); 292 293export function validate<T extends { $type: string }>( 294 v: unknown, 295 id: string, 296 hash: string, 297 requiredType: true, 298): ValidationResult<T>; 299export function validate<T extends { $type?: string }>( 300 v: unknown, 301 id: string, 302 hash: string, 303 requiredType?: false, 304): ValidationResult<T>; 305export function validate( 306 v: unknown, 307 id: string, 308 hash: string, 309 requiredType?: boolean, 310): ValidationResult { 311 return (requiredType ? is$typed : maybe$typed)(v, id, hash) 312 ? lexicons.validate(`${id}#${hash}`, v) 313 : { 314 success: false, 315 error: new ValidationError( 316 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 317 ), 318 }; 319} 320 321export const ids = { 322 NetworkCosmikCard: 'network.cosmik.card', 323 NetworkCosmikCollection: 'network.cosmik.collection', 324 NetworkCosmikCollectionLink: 'network.cosmik.collectionLink', 325 NetworkCosmikDefs: 'network.cosmik.defs', 326 ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef', 327} as const;