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 flat: {
124 type: 'boolean',
125 description:
126 "If true, the subfs record's root entries are merged (flattened) into the parent directory, replacing the subfs entry. If false (default), the subfs entries are placed in a subdirectory with the subfs entry's name. Flat merging is useful for splitting large directories across multiple records while maintaining a flat structure.",
127 },
128 },
129 },
130 },
131 },
132 PlaceWispSubfs: {
133 lexicon: 1,
134 id: 'place.wisp.subfs',
135 defs: {
136 main: {
137 type: 'record',
138 description:
139 'Virtual filesystem subtree referenced by place.wisp.fs records. When a subfs entry is expanded, its root entries are merged (flattened) into the parent directory, allowing large directories to be split across multiple records while maintaining a flat structure.',
140 record: {
141 type: 'object',
142 required: ['root', 'createdAt'],
143 properties: {
144 root: {
145 type: 'ref',
146 ref: 'lex:place.wisp.subfs#directory',
147 },
148 fileCount: {
149 type: 'integer',
150 minimum: 0,
151 maximum: 1000,
152 },
153 createdAt: {
154 type: 'string',
155 format: 'datetime',
156 },
157 },
158 },
159 },
160 file: {
161 type: 'object',
162 required: ['type', 'blob'],
163 properties: {
164 type: {
165 type: 'string',
166 const: 'file',
167 },
168 blob: {
169 type: 'blob',
170 accept: ['*/*'],
171 maxSize: 1000000000,
172 description: 'Content blob ref',
173 },
174 encoding: {
175 type: 'string',
176 enum: ['gzip'],
177 description: 'Content encoding (e.g., gzip for compressed files)',
178 },
179 mimeType: {
180 type: 'string',
181 description: 'Original MIME type before compression',
182 },
183 base64: {
184 type: 'boolean',
185 description:
186 'True if blob content is base64-encoded (used to bypass PDS content sniffing)',
187 },
188 },
189 },
190 directory: {
191 type: 'object',
192 required: ['type', 'entries'],
193 properties: {
194 type: {
195 type: 'string',
196 const: 'directory',
197 },
198 entries: {
199 type: 'array',
200 maxLength: 500,
201 items: {
202 type: 'ref',
203 ref: 'lex:place.wisp.subfs#entry',
204 },
205 },
206 },
207 },
208 entry: {
209 type: 'object',
210 required: ['name', 'node'],
211 properties: {
212 name: {
213 type: 'string',
214 maxLength: 255,
215 },
216 node: {
217 type: 'union',
218 refs: [
219 'lex:place.wisp.subfs#file',
220 'lex:place.wisp.subfs#directory',
221 'lex:place.wisp.subfs#subfs',
222 ],
223 },
224 },
225 },
226 subfs: {
227 type: 'object',
228 required: ['type', 'subject'],
229 properties: {
230 type: {
231 type: 'string',
232 const: 'subfs',
233 },
234 subject: {
235 type: 'string',
236 format: 'at-uri',
237 description:
238 "AT-URI pointing to another place.wisp.subfs record for nested subtrees. When expanded, the referenced record's root entries are merged (flattened) into the parent directory, allowing recursive splitting of large directory structures.",
239 },
240 },
241 },
242 },
243 },
244} as const satisfies Record<string, LexiconDoc>
245export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]
246export const lexicons: Lexicons = new Lexicons(schemas)
247
248export function validate<T extends { $type: string }>(
249 v: unknown,
250 id: string,
251 hash: string,
252 requiredType: true,
253): ValidationResult<T>
254export function validate<T extends { $type?: string }>(
255 v: unknown,
256 id: string,
257 hash: string,
258 requiredType?: false,
259): ValidationResult<T>
260export function validate(
261 v: unknown,
262 id: string,
263 hash: string,
264 requiredType?: boolean,
265): ValidationResult {
266 return (requiredType ? is$typed : maybe$typed)(v, id, hash)
267 ? lexicons.validate(`${id}#${hash}`, v)
268 : {
269 success: false,
270 error: new ValidationError(
271 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`,
272 ),
273 }
274}
275
276export const ids = {
277 PlaceWispFs: 'place.wisp.fs',
278 PlaceWispSubfs: 'place.wisp.subfs',
279} as const