Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place
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: 1000000000, 55 description: 'Content blob ref', 56 }, 57 encoding: { 58 type: 'string', 59 enum: ['gzip'], 60 description: 'Content encoding (e.g., gzip for compressed files)', 61 }, 62 mimeType: { 63 type: 'string', 64 description: 'Original MIME type before compression', 65 }, 66 base64: { 67 type: 'boolean', 68 description: 69 'True if blob content is base64-encoded (used to bypass PDS content sniffing)', 70 }, 71 }, 72 }, 73 directory: { 74 type: 'object', 75 required: ['type', 'entries'], 76 properties: { 77 type: { 78 type: 'string', 79 const: 'directory', 80 }, 81 entries: { 82 type: 'array', 83 maxLength: 500, 84 items: { 85 type: 'ref', 86 ref: 'lex:place.wisp.fs#entry', 87 }, 88 }, 89 }, 90 }, 91 entry: { 92 type: 'object', 93 required: ['name', 'node'], 94 properties: { 95 name: { 96 type: 'string', 97 maxLength: 255, 98 }, 99 node: { 100 type: 'union', 101 refs: [ 102 'lex:place.wisp.fs#file', 103 'lex:place.wisp.fs#directory', 104 'lex:place.wisp.fs#subfs', 105 ], 106 }, 107 }, 108 }, 109 subfs: { 110 type: 'object', 111 required: ['type', 'subject'], 112 properties: { 113 type: { 114 type: 'string', 115 const: 'subfs', 116 }, 117 subject: { 118 type: 'string', 119 format: 'at-uri', 120 description: 121 'AT-URI pointing to a place.wisp.subfs record containing this subtree', 122 }, 123 }, 124 }, 125 }, 126 }, 127 PlaceWispSubfs: { 128 lexicon: 1, 129 id: 'place.wisp.subfs', 130 defs: { 131 main: { 132 type: 'record', 133 description: 134 'Virtual filesystem manifest within a place.wisp.fs record', 135 record: { 136 type: 'object', 137 required: ['root', 'createdAt'], 138 properties: { 139 root: { 140 type: 'ref', 141 ref: 'lex:place.wisp.subfs#directory', 142 }, 143 fileCount: { 144 type: 'integer', 145 minimum: 0, 146 maximum: 1000, 147 }, 148 createdAt: { 149 type: 'string', 150 format: 'datetime', 151 }, 152 }, 153 }, 154 }, 155 file: { 156 type: 'object', 157 required: ['type', 'blob'], 158 properties: { 159 type: { 160 type: 'string', 161 const: 'file', 162 }, 163 blob: { 164 type: 'blob', 165 accept: ['*/*'], 166 maxSize: 1000000000, 167 description: 'Content blob ref', 168 }, 169 encoding: { 170 type: 'string', 171 enum: ['gzip'], 172 description: 'Content encoding (e.g., gzip for compressed files)', 173 }, 174 mimeType: { 175 type: 'string', 176 description: 'Original MIME type before compression', 177 }, 178 base64: { 179 type: 'boolean', 180 description: 181 'True if blob content is base64-encoded (used to bypass PDS content sniffing)', 182 }, 183 }, 184 }, 185 directory: { 186 type: 'object', 187 required: ['type', 'entries'], 188 properties: { 189 type: { 190 type: 'string', 191 const: 'directory', 192 }, 193 entries: { 194 type: 'array', 195 maxLength: 500, 196 items: { 197 type: 'ref', 198 ref: 'lex:place.wisp.subfs#entry', 199 }, 200 }, 201 }, 202 }, 203 entry: { 204 type: 'object', 205 required: ['name', 'node'], 206 properties: { 207 name: { 208 type: 'string', 209 maxLength: 255, 210 }, 211 node: { 212 type: 'union', 213 refs: [ 214 'lex:place.wisp.subfs#file', 215 'lex:place.wisp.subfs#directory', 216 'lex:place.wisp.subfs#subfs', 217 ], 218 }, 219 }, 220 }, 221 subfs: { 222 type: 'object', 223 required: ['type', 'subject'], 224 properties: { 225 type: { 226 type: 'string', 227 const: 'subfs', 228 }, 229 subject: { 230 type: 'string', 231 format: 'at-uri', 232 description: 233 'AT-URI pointing to another place.wisp.subfs record for nested subtrees', 234 }, 235 }, 236 }, 237 }, 238 }, 239} as const satisfies Record<string, LexiconDoc> 240export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] 241export const lexicons: Lexicons = new Lexicons(schemas) 242 243export function validate<T extends { $type: string }>( 244 v: unknown, 245 id: string, 246 hash: string, 247 requiredType: true, 248): ValidationResult<T> 249export function validate<T extends { $type?: string }>( 250 v: unknown, 251 id: string, 252 hash: string, 253 requiredType?: false, 254): ValidationResult<T> 255export function validate( 256 v: unknown, 257 id: string, 258 hash: string, 259 requiredType?: boolean, 260): ValidationResult { 261 return (requiredType ? is$typed : maybe$typed)(v, id, hash) 262 ? lexicons.validate(`${id}#${hash}`, v) 263 : { 264 success: false, 265 error: new ValidationError( 266 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 267 ), 268 } 269} 270 271export const ids = { 272 PlaceWispFs: 'place.wisp.fs', 273 PlaceWispSubfs: 'place.wisp.subfs', 274} as const