Skip to content

Commit 0bdd610

Browse files
committed
feat: json schema
1 parent 0c5c0b0 commit 0bdd610

File tree

1 file changed

+294
-0
lines changed

1 file changed

+294
-0
lines changed

routes/schema/andromeda.json.ts

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
export function handler(): Response {
2+
const schema = {
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"$id": "https://tryandromeda.dev/schema/andromeda.json",
5+
"title": "Andromeda Configuration Schema",
6+
"description": "Schema for Andromeda runtime configuration files",
7+
"type": "object",
8+
"properties": {
9+
"runtime": {
10+
"$ref": "#/definitions/RuntimeConfig"
11+
},
12+
"format": {
13+
"$ref": "#/definitions/FormatConfig"
14+
},
15+
"lint": {
16+
"$ref": "#/definitions/LintConfig"
17+
},
18+
"tasks": {
19+
"type": "object",
20+
"description": "Task definitions",
21+
"additionalProperties": {
22+
"$ref": "#/definitions/TaskDefinition"
23+
}
24+
},
25+
"imports": {
26+
"type": "object",
27+
"description": "Direct module specifier mappings (Web Import Maps spec)",
28+
"additionalProperties": {
29+
"type": "string"
30+
}
31+
},
32+
"scopes": {
33+
"type": "object",
34+
"description": "Scope-specific mappings (Web Import Maps spec)",
35+
"additionalProperties": {
36+
"type": "object",
37+
"additionalProperties": {
38+
"type": "string"
39+
}
40+
}
41+
},
42+
"integrity": {
43+
"type": "object",
44+
"description": "Integrity metadata mappings (Web Import Maps spec)",
45+
"additionalProperties": {
46+
"type": "string"
47+
}
48+
},
49+
"import_map_files": {
50+
"type": "array",
51+
"description": "Additional import map files to load (Andromeda extension)",
52+
"items": {
53+
"type": "string"
54+
}
55+
},
56+
"name": {
57+
"type": "string",
58+
"description": "Project name"
59+
},
60+
"version": {
61+
"type": "string",
62+
"description": "Project version"
63+
},
64+
"description": {
65+
"type": "string",
66+
"description": "Project description"
67+
},
68+
"author": {
69+
"type": "string",
70+
"description": "Project author(s)"
71+
},
72+
"license": {
73+
"type": "string",
74+
"description": "License"
75+
}
76+
},
77+
"additionalProperties": false,
78+
"definitions": {
79+
"RuntimeConfig": {
80+
"type": "object",
81+
"description": "Runtime execution configuration",
82+
"properties": {
83+
"no_strict": {
84+
"type": "boolean",
85+
"description": "Disable strict mode",
86+
"default": false
87+
},
88+
"verbose": {
89+
"type": "boolean",
90+
"description": "Enable verbose output",
91+
"default": false
92+
},
93+
"disable_gc": {
94+
"type": "boolean",
95+
"description": "Disable garbage collection (for debugging)",
96+
"default": false
97+
},
98+
"print_internals": {
99+
"type": "boolean",
100+
"description": "Print internal debugging information",
101+
"default": false
102+
},
103+
"expose_internals": {
104+
"type": "boolean",
105+
"description": "Expose Nova internal APIs",
106+
"default": false
107+
},
108+
"include": {
109+
"type": "array",
110+
"description": "List of files to include in runtime",
111+
"items": {
112+
"type": "string"
113+
},
114+
"default": []
115+
},
116+
"exclude": {
117+
"type": "array",
118+
"description": "List of files to exclude from runtime",
119+
"items": {
120+
"type": "string"
121+
},
122+
"default": []
123+
},
124+
"timeout": {
125+
"type": "integer",
126+
"description": "Runtime timeout in milliseconds",
127+
"minimum": 1
128+
}
129+
},
130+
"additionalProperties": false
131+
},
132+
"FormatConfig": {
133+
"type": "object",
134+
"description": "Code formatting configuration",
135+
"properties": {
136+
"line_width": {
137+
"type": "integer",
138+
"description": "Line width for formatting",
139+
"minimum": 20,
140+
"maximum": 500,
141+
"default": 80
142+
},
143+
"use_tabs": {
144+
"type": "boolean",
145+
"description": "Use tabs instead of spaces",
146+
"default": false
147+
},
148+
"tab_width": {
149+
"type": "integer",
150+
"description": "Tab width",
151+
"minimum": 1,
152+
"maximum": 16,
153+
"default": 2
154+
},
155+
"trailing_comma": {
156+
"type": "boolean",
157+
"description": "Trailing commas",
158+
"default": false
159+
},
160+
"semicolons": {
161+
"type": "boolean",
162+
"description": "Semicolons preference",
163+
"default": true
164+
},
165+
"single_quotes": {
166+
"type": "boolean",
167+
"description": "Single quotes preference",
168+
"default": false
169+
},
170+
"include": {
171+
"type": "array",
172+
"description": "Files or directories to include (glob patterns)",
173+
"items": {
174+
"type": "string"
175+
},
176+
"default": []
177+
},
178+
"exclude": {
179+
"type": "array",
180+
"description": "Files or directories to exclude (glob patterns)",
181+
"items": {
182+
"type": "string"
183+
},
184+
"default": []
185+
}
186+
},
187+
"additionalProperties": false
188+
},
189+
"LintConfig": {
190+
"type": "object",
191+
"description": "Linting configuration",
192+
"properties": {
193+
"enabled": {
194+
"type": "boolean",
195+
"description": "Enable linting",
196+
"default": true
197+
},
198+
"rules": {
199+
"type": "array",
200+
"description": "Lint rules to enable",
201+
"items": {
202+
"type": "string"
203+
},
204+
"default": []
205+
},
206+
"disabled_rules": {
207+
"type": "array",
208+
"description": "Lint rules to disable",
209+
"items": {
210+
"type": "string"
211+
},
212+
"default": []
213+
},
214+
"max_warnings": {
215+
"type": "integer",
216+
"description": "Maximum number of warnings before error",
217+
"minimum": 1
218+
},
219+
"include": {
220+
"type": "array",
221+
"description": "Files or directories to include (glob patterns)",
222+
"items": {
223+
"type": "string"
224+
},
225+
"default": []
226+
},
227+
"exclude": {
228+
"type": "array",
229+
"description": "Files or directories to exclude (glob patterns)",
230+
"items": {
231+
"type": "string"
232+
},
233+
"default": []
234+
}
235+
},
236+
"additionalProperties": false
237+
},
238+
"TaskDefinition": {
239+
"oneOf": [
240+
{
241+
"type": "string",
242+
"description": "Simple string command"
243+
},
244+
{
245+
"type": "object",
246+
"description": "Complex task definition",
247+
"properties": {
248+
"description": {
249+
"type": "string",
250+
"description": "Description of the task"
251+
},
252+
"command": {
253+
"type": "string",
254+
"description": "Command to execute"
255+
},
256+
"dependencies": {
257+
"type": "array",
258+
"description": "Dependencies that must run before this task",
259+
"items": {
260+
"type": "string"
261+
},
262+
"default": []
263+
},
264+
"cwd": {
265+
"type": "string",
266+
"description": "Working directory for the task"
267+
},
268+
"env": {
269+
"type": "object",
270+
"description": "Environment variables for the task",
271+
"additionalProperties": {
272+
"type": "string"
273+
},
274+
"default": {}
275+
}
276+
},
277+
"required": ["command"],
278+
"additionalProperties": false
279+
}
280+
]
281+
}
282+
}
283+
};
284+
285+
return new Response(JSON.stringify(schema, null, 2), {
286+
headers: {
287+
"Content-Type": "application/schema+json; charset=utf-8",
288+
"Cache-Control": "public, max-age=86400", // Cache for 24 hours
289+
"Access-Control-Allow-Origin": "*", // Allow cross-origin requests for schema usage
290+
"Access-Control-Allow-Methods": "GET",
291+
"Access-Control-Allow-Headers": "Content-Type",
292+
},
293+
});
294+
}

0 commit comments

Comments
 (0)