tova 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tova.js +1401 -111
- package/package.json +4 -7
- package/src/analyzer/analyzer.js +831 -709
- package/src/analyzer/client-analyzer.js +191 -0
- package/src/analyzer/server-analyzer.js +467 -0
- package/src/analyzer/types.js +20 -4
- package/src/codegen/base-codegen.js +467 -109
- package/src/codegen/client-codegen.js +92 -42
- package/src/codegen/codegen.js +65 -5
- package/src/codegen/server-codegen.js +290 -36
- package/src/diagnostics/error-codes.js +255 -0
- package/src/diagnostics/formatter.js +150 -28
- package/src/docs/generator.js +390 -0
- package/src/lexer/lexer.js +305 -63
- package/src/lexer/tokens.js +19 -0
- package/src/lsp/server.js +892 -30
- package/src/parser/ast.js +81 -368
- package/src/parser/client-ast.js +138 -0
- package/src/parser/client-parser.js +504 -0
- package/src/parser/parser.js +491 -1064
- package/src/parser/server-ast.js +240 -0
- package/src/parser/server-parser.js +602 -0
- package/src/runtime/array-proto.js +32 -0
- package/src/runtime/embedded.js +1 -1
- package/src/runtime/reactivity.js +191 -10
- package/src/stdlib/advanced-collections.js +81 -0
- package/src/stdlib/inline.js +549 -6
- package/src/version.js +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Server-specific AST Node definitions for the Tova language
|
|
2
|
+
// Extracted from ast.js for lazy loading — only loaded when server { } blocks are used.
|
|
3
|
+
|
|
4
|
+
export class RouteDeclaration {
|
|
5
|
+
constructor(method, path, handler, loc, decorators = [], bodyType = null, responseType = null) {
|
|
6
|
+
this.type = 'RouteDeclaration';
|
|
7
|
+
this.method = method; // GET, POST, PUT, DELETE, PATCH
|
|
8
|
+
this.path = path; // string literal
|
|
9
|
+
this.handler = handler; // Identifier or FunctionDeclaration
|
|
10
|
+
this.decorators = decorators; // Array of { name, args } for "with auth, role("admin")"
|
|
11
|
+
this.bodyType = bodyType; // TypeAnnotation — request body type (e.g., body: User)
|
|
12
|
+
this.responseType = responseType; // TypeAnnotation — response type (e.g., -> [User])
|
|
13
|
+
this.loc = loc;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class MiddlewareDeclaration {
|
|
18
|
+
constructor(name, params, body, loc) {
|
|
19
|
+
this.type = 'MiddlewareDeclaration';
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.params = params; // Array of Parameter nodes (req, next)
|
|
22
|
+
this.body = body; // BlockStatement
|
|
23
|
+
this.loc = loc;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class HealthCheckDeclaration {
|
|
28
|
+
constructor(path, loc) {
|
|
29
|
+
this.type = 'HealthCheckDeclaration';
|
|
30
|
+
this.path = path; // string literal, e.g. "/health"
|
|
31
|
+
this.loc = loc;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class CorsDeclaration {
|
|
36
|
+
constructor(config, loc) {
|
|
37
|
+
this.type = 'CorsDeclaration';
|
|
38
|
+
this.config = config; // { origins: ArrayLiteral, methods: ArrayLiteral, headers: ArrayLiteral }
|
|
39
|
+
this.loc = loc;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class ErrorHandlerDeclaration {
|
|
44
|
+
constructor(params, body, loc) {
|
|
45
|
+
this.type = 'ErrorHandlerDeclaration';
|
|
46
|
+
this.params = params; // Array of Parameter nodes (err, req)
|
|
47
|
+
this.body = body; // BlockStatement
|
|
48
|
+
this.loc = loc;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class WebSocketDeclaration {
|
|
53
|
+
constructor(handlers, loc, config = null) {
|
|
54
|
+
this.type = 'WebSocketDeclaration';
|
|
55
|
+
this.handlers = handlers; // { on_open, on_message, on_close, on_error } — each is { params, body } or null
|
|
56
|
+
this.config = config; // { auth: expression } or null
|
|
57
|
+
this.loc = loc;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class StaticDeclaration {
|
|
62
|
+
constructor(path, dir, loc, fallback = null) {
|
|
63
|
+
this.type = 'StaticDeclaration';
|
|
64
|
+
this.path = path; // URL prefix, e.g. "/public"
|
|
65
|
+
this.dir = dir; // directory path, e.g. "./public"
|
|
66
|
+
this.fallback = fallback; // fallback file, e.g. "index.html"
|
|
67
|
+
this.loc = loc;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class DiscoverDeclaration {
|
|
72
|
+
constructor(peerName, urlExpression, loc, config = null) {
|
|
73
|
+
this.type = 'DiscoverDeclaration';
|
|
74
|
+
this.peerName = peerName; // string — the peer server name
|
|
75
|
+
this.urlExpression = urlExpression; // Expression — the URL
|
|
76
|
+
this.config = config; // { threshold, timeout } or null
|
|
77
|
+
this.loc = loc;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class AuthDeclaration {
|
|
82
|
+
constructor(config, loc) {
|
|
83
|
+
this.type = 'AuthDeclaration';
|
|
84
|
+
this.config = config; // { type, secret, ... } object config
|
|
85
|
+
this.loc = loc;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class MaxBodyDeclaration {
|
|
90
|
+
constructor(limit, loc) {
|
|
91
|
+
this.type = 'MaxBodyDeclaration';
|
|
92
|
+
this.limit = limit; // Expression — max body size in bytes
|
|
93
|
+
this.loc = loc;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class RouteGroupDeclaration {
|
|
98
|
+
constructor(prefix, body, loc, version = null) {
|
|
99
|
+
this.type = 'RouteGroupDeclaration';
|
|
100
|
+
this.prefix = prefix; // string — URL prefix, e.g. "/api/v1"
|
|
101
|
+
this.body = body; // Array of server statements
|
|
102
|
+
this.version = version; // version config: { version, deprecated, sunset } or null
|
|
103
|
+
this.loc = loc;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class RateLimitDeclaration {
|
|
108
|
+
constructor(config, loc) {
|
|
109
|
+
this.type = 'RateLimitDeclaration';
|
|
110
|
+
this.config = config;
|
|
111
|
+
this.loc = loc;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class LifecycleHookDeclaration {
|
|
116
|
+
constructor(hook, params, body, loc) {
|
|
117
|
+
this.type = 'LifecycleHookDeclaration';
|
|
118
|
+
this.hook = hook; // "start" or "stop"
|
|
119
|
+
this.params = params;
|
|
120
|
+
this.body = body;
|
|
121
|
+
this.loc = loc;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class SubscribeDeclaration {
|
|
126
|
+
constructor(event, params, body, loc) {
|
|
127
|
+
this.type = 'SubscribeDeclaration';
|
|
128
|
+
this.event = event; // string — event name
|
|
129
|
+
this.params = params;
|
|
130
|
+
this.body = body;
|
|
131
|
+
this.loc = loc;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export class EnvDeclaration {
|
|
136
|
+
constructor(name, typeAnnotation, defaultValue, loc) {
|
|
137
|
+
this.type = 'EnvDeclaration';
|
|
138
|
+
this.name = name;
|
|
139
|
+
this.typeAnnotation = typeAnnotation;
|
|
140
|
+
this.defaultValue = defaultValue;
|
|
141
|
+
this.loc = loc;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export class ScheduleDeclaration {
|
|
146
|
+
constructor(pattern, name, params, body, loc) {
|
|
147
|
+
this.type = 'ScheduleDeclaration';
|
|
148
|
+
this.pattern = pattern; // string — interval or cron pattern
|
|
149
|
+
this.name = name; // optional function name
|
|
150
|
+
this.params = params;
|
|
151
|
+
this.body = body;
|
|
152
|
+
this.loc = loc;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export class UploadDeclaration {
|
|
157
|
+
constructor(config, loc) {
|
|
158
|
+
this.type = 'UploadDeclaration';
|
|
159
|
+
this.config = config; // { max_size, allowed_types, ... }
|
|
160
|
+
this.loc = loc;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export class SessionDeclaration {
|
|
165
|
+
constructor(config, loc) {
|
|
166
|
+
this.type = 'SessionDeclaration';
|
|
167
|
+
this.config = config; // { secret, max_age, cookie_name, ... }
|
|
168
|
+
this.loc = loc;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export class DbDeclaration {
|
|
173
|
+
constructor(config, loc) {
|
|
174
|
+
this.type = 'DbDeclaration';
|
|
175
|
+
this.config = config; // { path, wal, ... }
|
|
176
|
+
this.loc = loc;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export class TlsDeclaration {
|
|
181
|
+
constructor(config, loc) {
|
|
182
|
+
this.type = 'TlsDeclaration';
|
|
183
|
+
this.config = config; // { cert, key, ... }
|
|
184
|
+
this.loc = loc;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export class CompressionDeclaration {
|
|
189
|
+
constructor(config, loc) {
|
|
190
|
+
this.type = 'CompressionDeclaration';
|
|
191
|
+
this.config = config; // { enabled, min_size, ... }
|
|
192
|
+
this.loc = loc;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export class BackgroundJobDeclaration {
|
|
197
|
+
constructor(name, params, body, loc) {
|
|
198
|
+
this.type = 'BackgroundJobDeclaration';
|
|
199
|
+
this.name = name;
|
|
200
|
+
this.params = params;
|
|
201
|
+
this.body = body;
|
|
202
|
+
this.loc = loc;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export class CacheDeclaration {
|
|
207
|
+
constructor(config, loc) {
|
|
208
|
+
this.type = 'CacheDeclaration';
|
|
209
|
+
this.config = config; // { max_age, stale_while_revalidate, ... }
|
|
210
|
+
this.loc = loc;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class SseDeclaration {
|
|
215
|
+
constructor(path, params, body, loc) {
|
|
216
|
+
this.type = 'SseDeclaration';
|
|
217
|
+
this.path = path; // string — SSE endpoint path
|
|
218
|
+
this.params = params; // Array of Parameter nodes
|
|
219
|
+
this.body = body; // BlockStatement
|
|
220
|
+
this.loc = loc;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export class ModelDeclaration {
|
|
225
|
+
constructor(name, config, loc) {
|
|
226
|
+
this.type = 'ModelDeclaration';
|
|
227
|
+
this.name = name; // string — type name to generate CRUD for
|
|
228
|
+
this.config = config; // { table, timestamps, ... } or null
|
|
229
|
+
this.loc = loc;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export class AiConfigDeclaration {
|
|
234
|
+
constructor(name, config, loc) {
|
|
235
|
+
this.type = 'AiConfigDeclaration';
|
|
236
|
+
this.name = name; // optional string name (null for default)
|
|
237
|
+
this.config = config; // key-value config object
|
|
238
|
+
this.loc = loc;
|
|
239
|
+
}
|
|
240
|
+
}
|