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', 'hash'],
46 properties: {
47 type: {
48 type: 'string',
49 const: 'file',
50 },
51 hash: {
52 type: 'string',
53 description: 'Content blob hash',
54 },
55 },
56 },
57 directory: {
58 type: 'object',
59 required: ['type', 'entries'],
60 properties: {
61 type: {
62 type: 'string',
63 const: 'directory',
64 },
65 entries: {
66 type: 'array',
67 maxLength: 500,
68 items: {
69 type: 'ref',
70 ref: 'lex:place.wisp.fs#entry',
71 },
72 },
73 },
74 },
75 entry: {
76 type: 'object',
77 required: ['name', 'node'],
78 properties: {
79 name: {
80 type: 'string',
81 maxLength: 255,
82 },
83 node: {
84 type: 'union',
85 refs: ['lex:place.wisp.fs#file', 'lex:place.wisp.fs#directory'],
86 },
87 },
88 },
89 },
90 },
91} as const satisfies Record<string, LexiconDoc>
92export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]
93export const lexicons: Lexicons = new Lexicons(schemas)
94
95export function validate<T extends { $type: string }>(
96 v: unknown,
97 id: string,
98 hash: string,
99 requiredType: true,
100): ValidationResult<T>
101export function validate<T extends { $type?: string }>(
102 v: unknown,
103 id: string,
104 hash: string,
105 requiredType?: false,
106): ValidationResult<T>
107export function validate(
108 v: unknown,
109 id: string,
110 hash: string,
111 requiredType?: boolean,
112): ValidationResult {
113 return (requiredType ? is$typed : maybe$typed)(v, id, hash)
114 ? lexicons.validate(`${id}#${hash}`, v)
115 : {
116 success: false,
117 error: new ValidationError(
118 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`,
119 ),
120 }
121}
122
123export const ids = {
124 PlaceWispFs: 'place.wisp.fs',
125} as const