Monorepo for Wisp.place. A static site hosting service built on top of the AT Protocol.
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 PlaceWispFs: { 14 lexicon: 1, 15 id: 'place.wisp.fs', 16 defs: { 17 main: { 18 type: 'record', 19 description: 'Virtual filesystem manifest for a Wisp site', 20 record: { 21 type: 'object', 22 required: ['site', 'root', 'createdAt'], 23 properties: { 24 site: { 25 type: 'string', 26 }, 27 root: { 28 type: 'ref', 29 ref: 'lex:place.wisp.fs#directory', 30 }, 31 fileCount: { 32 type: 'integer', 33 minimum: 0, 34 maximum: 1000, 35 }, 36 createdAt: { 37 type: 'string', 38 format: 'datetime', 39 }, 40 }, 41 }, 42 }, 43 file: { 44 type: 'object', 45 required: ['type', 'blob'], 46 properties: { 47 type: { 48 type: 'string', 49 const: 'file', 50 }, 51 blob: { 52 type: 'blob', 53 accept: ['*/*'], 54 maxSize: 1000000, 55 description: 'Content blob ref', 56 }, 57 }, 58 }, 59 directory: { 60 type: 'object', 61 required: ['type', 'entries'], 62 properties: { 63 type: { 64 type: 'string', 65 const: 'directory', 66 }, 67 entries: { 68 type: 'array', 69 maxLength: 500, 70 items: { 71 type: 'ref', 72 ref: 'lex:place.wisp.fs#entry', 73 }, 74 }, 75 }, 76 }, 77 entry: { 78 type: 'object', 79 required: ['name', 'node'], 80 properties: { 81 name: { 82 type: 'string', 83 maxLength: 255, 84 }, 85 node: { 86 type: 'union', 87 refs: ['lex:place.wisp.fs#file', 'lex:place.wisp.fs#directory'], 88 }, 89 }, 90 }, 91 }, 92 }, 93} as const satisfies Record<string, LexiconDoc> 94export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] 95export const lexicons: Lexicons = new Lexicons(schemas) 96 97export function validate<T extends { $type: string }>( 98 v: unknown, 99 id: string, 100 hash: string, 101 requiredType: true, 102): ValidationResult<T> 103export function validate<T extends { $type?: string }>( 104 v: unknown, 105 id: string, 106 hash: string, 107 requiredType?: false, 108): ValidationResult<T> 109export function validate( 110 v: unknown, 111 id: string, 112 hash: string, 113 requiredType?: boolean, 114): ValidationResult { 115 return (requiredType ? is$typed : maybe$typed)(v, id, hash) 116 ? lexicons.validate(`${id}#${hash}`, v) 117 : { 118 success: false, 119 error: new ValidationError( 120 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 121 ), 122 } 123} 124 125export const ids = { 126 PlaceWispFs: 'place.wisp.fs', 127} as const