@vertz/compiler 0.0.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/dist/index.d.ts +724 -0
- package/dist/index.js +2814 -0
- package/package.json +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
type DiagnosticSeverity = "error" | "warning" | "info";
|
|
2
|
+
type DiagnosticCode = "VERTZ_SCHEMA_NAMING" | "VERTZ_SCHEMA_PLACEMENT" | "VERTZ_SCHEMA_EXECUTION" | "VERTZ_SCHEMA_MISSING_ID" | "VERTZ_SCHEMA_DYNAMIC_NAME" | "VERTZ_MODULE_CIRCULAR" | "VERTZ_MODULE_EXPORT_INVALID" | "VERTZ_MODULE_IMPORT_MISSING" | "VERTZ_MODULE_DUPLICATE_NAME" | "VERTZ_MODULE_DYNAMIC_NAME" | "VERTZ_MODULE_OPTIONS_INVALID" | "VERTZ_MODULE_WRONG_OWNERSHIP" | "VERTZ_SERVICE_INJECT_MISSING" | "VERTZ_SERVICE_UNUSED" | "VERTZ_SERVICE_DYNAMIC_NAME" | "VERTZ_ENV_MISSING_DEFAULT" | "VERTZ_ENV_DUPLICATE" | "VERTZ_ENV_DYNAMIC_CONFIG" | "VERTZ_MW_MISSING_NAME" | "VERTZ_MW_MISSING_HANDLER" | "VERTZ_MW_DYNAMIC_NAME" | "VERTZ_MW_NON_OBJECT_CONFIG" | "VERTZ_MW_REQUIRES_UNSATISFIED" | "VERTZ_MW_PROVIDES_COLLISION" | "VERTZ_MW_ORDER_INVALID" | "VERTZ_RT_UNKNOWN_MODULE_DEF" | "VERTZ_RT_DYNAMIC_PATH" | "VERTZ_RT_MISSING_HANDLER" | "VERTZ_RT_MISSING_PREFIX" | "VERTZ_RT_DYNAMIC_CONFIG" | "VERTZ_RT_INVALID_PATH" | "VERTZ_ROUTE_DUPLICATE" | "VERTZ_ROUTE_PARAM_MISMATCH" | "VERTZ_ROUTE_MISSING_RESPONSE" | "VERTZ_APP_MISSING" | "VERTZ_APP_NOT_FOUND" | "VERTZ_APP_DUPLICATE" | "VERTZ_APP_BASEPATH_FORMAT" | "VERTZ_APP_INLINE_MODULE" | "VERTZ_DEP_CYCLE" | "VERTZ_DEP_CIRCULAR" | "VERTZ_DEP_UNRESOLVED_INJECT" | "VERTZ_DEP_INIT_ORDER" | "VERTZ_CTX_COLLISION" | "VERTZ_DEAD_CODE";
|
|
3
|
+
interface SourceContext {
|
|
4
|
+
lines: {
|
|
5
|
+
number: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
highlightStart: number;
|
|
9
|
+
highlightLength: number;
|
|
10
|
+
}
|
|
11
|
+
interface Diagnostic {
|
|
12
|
+
severity: DiagnosticSeverity;
|
|
13
|
+
code: DiagnosticCode;
|
|
14
|
+
message: string;
|
|
15
|
+
file?: string;
|
|
16
|
+
line?: number;
|
|
17
|
+
column?: number;
|
|
18
|
+
endLine?: number;
|
|
19
|
+
endColumn?: number;
|
|
20
|
+
suggestion?: string;
|
|
21
|
+
sourceContext?: SourceContext;
|
|
22
|
+
}
|
|
23
|
+
type CreateDiagnosticOptions = Diagnostic;
|
|
24
|
+
declare function createDiagnostic(options: CreateDiagnosticOptions): Diagnostic;
|
|
25
|
+
declare function createDiagnosticFromLocation(location: SourceLocation, options: Omit<CreateDiagnosticOptions, "file" | "line" | "column">): Diagnostic;
|
|
26
|
+
declare function hasErrors(diagnostics: readonly Diagnostic[]): boolean;
|
|
27
|
+
declare function filterBySeverity(diagnostics: readonly Diagnostic[], severity: DiagnosticSeverity): Diagnostic[];
|
|
28
|
+
declare function mergeDiagnostics(a: readonly Diagnostic[], b: readonly Diagnostic[]): Diagnostic[];
|
|
29
|
+
interface SourceLocation {
|
|
30
|
+
sourceFile: string;
|
|
31
|
+
sourceLine: number;
|
|
32
|
+
sourceColumn: number;
|
|
33
|
+
}
|
|
34
|
+
interface AppIR {
|
|
35
|
+
app: AppDefinition;
|
|
36
|
+
env?: EnvIR;
|
|
37
|
+
modules: ModuleIR[];
|
|
38
|
+
middleware: MiddlewareIR[];
|
|
39
|
+
schemas: SchemaIR[];
|
|
40
|
+
dependencyGraph: DependencyGraphIR;
|
|
41
|
+
diagnostics: Diagnostic[];
|
|
42
|
+
}
|
|
43
|
+
interface AppDefinition extends SourceLocation {
|
|
44
|
+
basePath: string;
|
|
45
|
+
version?: string;
|
|
46
|
+
globalMiddleware: MiddlewareRef[];
|
|
47
|
+
moduleRegistrations: ModuleRegistration[];
|
|
48
|
+
}
|
|
49
|
+
interface ModuleRegistration {
|
|
50
|
+
moduleName: string;
|
|
51
|
+
options?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface EnvIR extends SourceLocation {
|
|
54
|
+
loadFiles: string[];
|
|
55
|
+
schema?: SchemaRef;
|
|
56
|
+
variables: EnvVariableIR[];
|
|
57
|
+
}
|
|
58
|
+
interface EnvVariableIR {
|
|
59
|
+
name: string;
|
|
60
|
+
type: string;
|
|
61
|
+
hasDefault: boolean;
|
|
62
|
+
required: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface ModuleIR extends SourceLocation {
|
|
65
|
+
name: string;
|
|
66
|
+
imports: ImportRef[];
|
|
67
|
+
options?: SchemaRef;
|
|
68
|
+
services: ServiceIR[];
|
|
69
|
+
routers: RouterIR[];
|
|
70
|
+
exports: string[];
|
|
71
|
+
}
|
|
72
|
+
interface ImportRef {
|
|
73
|
+
localName: string;
|
|
74
|
+
sourceModule?: string;
|
|
75
|
+
sourceExport?: string;
|
|
76
|
+
isEnvImport: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface ServiceIR extends SourceLocation {
|
|
79
|
+
name: string;
|
|
80
|
+
moduleName: string;
|
|
81
|
+
inject: InjectRef[];
|
|
82
|
+
methods: ServiceMethodIR[];
|
|
83
|
+
}
|
|
84
|
+
interface InjectRef {
|
|
85
|
+
localName: string;
|
|
86
|
+
resolvedToken: string;
|
|
87
|
+
}
|
|
88
|
+
interface ServiceMethodIR {
|
|
89
|
+
name: string;
|
|
90
|
+
parameters: ServiceMethodParam[];
|
|
91
|
+
returnType: string;
|
|
92
|
+
}
|
|
93
|
+
interface ServiceMethodParam {
|
|
94
|
+
name: string;
|
|
95
|
+
type: string;
|
|
96
|
+
}
|
|
97
|
+
interface RouterIR extends SourceLocation {
|
|
98
|
+
name: string;
|
|
99
|
+
moduleName: string;
|
|
100
|
+
prefix: string;
|
|
101
|
+
inject: InjectRef[];
|
|
102
|
+
routes: RouteIR[];
|
|
103
|
+
}
|
|
104
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
105
|
+
interface RouteIR extends SourceLocation {
|
|
106
|
+
method: HttpMethod;
|
|
107
|
+
path: string;
|
|
108
|
+
fullPath: string;
|
|
109
|
+
operationId: string;
|
|
110
|
+
params?: SchemaRef;
|
|
111
|
+
query?: SchemaRef;
|
|
112
|
+
body?: SchemaRef;
|
|
113
|
+
headers?: SchemaRef;
|
|
114
|
+
response?: SchemaRef;
|
|
115
|
+
middleware: MiddlewareRef[];
|
|
116
|
+
description?: string;
|
|
117
|
+
tags: string[];
|
|
118
|
+
}
|
|
119
|
+
interface MiddlewareIR extends SourceLocation {
|
|
120
|
+
name: string;
|
|
121
|
+
inject: InjectRef[];
|
|
122
|
+
headers?: SchemaRef;
|
|
123
|
+
params?: SchemaRef;
|
|
124
|
+
query?: SchemaRef;
|
|
125
|
+
body?: SchemaRef;
|
|
126
|
+
requires?: SchemaRef;
|
|
127
|
+
provides?: SchemaRef;
|
|
128
|
+
}
|
|
129
|
+
interface MiddlewareRef {
|
|
130
|
+
name: string;
|
|
131
|
+
sourceFile: string;
|
|
132
|
+
}
|
|
133
|
+
interface SchemaIR extends SourceLocation {
|
|
134
|
+
name: string;
|
|
135
|
+
id?: string;
|
|
136
|
+
namingConvention: SchemaNameParts;
|
|
137
|
+
jsonSchema?: Record<string, unknown>;
|
|
138
|
+
isNamed: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface SchemaNameParts {
|
|
141
|
+
operation?: string;
|
|
142
|
+
entity?: string;
|
|
143
|
+
part?: string;
|
|
144
|
+
}
|
|
145
|
+
type SchemaRef = NamedSchemaRef | InlineSchemaRef;
|
|
146
|
+
interface NamedSchemaRef {
|
|
147
|
+
kind: "named";
|
|
148
|
+
schemaName: string;
|
|
149
|
+
sourceFile: string;
|
|
150
|
+
jsonSchema?: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
interface InlineSchemaRef {
|
|
153
|
+
kind: "inline";
|
|
154
|
+
sourceFile: string;
|
|
155
|
+
jsonSchema?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
interface ModuleDefContext {
|
|
158
|
+
moduleDefVariables: Map<string, string>;
|
|
159
|
+
}
|
|
160
|
+
interface DependencyGraphIR {
|
|
161
|
+
nodes: DependencyNode[];
|
|
162
|
+
edges: DependencyEdge[];
|
|
163
|
+
initializationOrder: string[];
|
|
164
|
+
circularDependencies: string[][];
|
|
165
|
+
}
|
|
166
|
+
type DependencyNodeKind = "module" | "service" | "router" | "middleware";
|
|
167
|
+
interface DependencyNode {
|
|
168
|
+
id: string;
|
|
169
|
+
kind: DependencyNodeKind;
|
|
170
|
+
name: string;
|
|
171
|
+
moduleName?: string;
|
|
172
|
+
}
|
|
173
|
+
type DependencyEdgeKind = "imports" | "inject" | "uses-middleware" | "exports";
|
|
174
|
+
interface DependencyEdge {
|
|
175
|
+
from: string;
|
|
176
|
+
to: string;
|
|
177
|
+
kind: DependencyEdgeKind;
|
|
178
|
+
}
|
|
179
|
+
import { Project } from "ts-morph";
|
|
180
|
+
interface SchemaConfig {
|
|
181
|
+
enforceNaming: boolean;
|
|
182
|
+
enforcePlacement: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface OpenAPIConfig {
|
|
185
|
+
output: string;
|
|
186
|
+
info: {
|
|
187
|
+
title: string;
|
|
188
|
+
version: string;
|
|
189
|
+
description?: string;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
interface ValidationConfig {
|
|
193
|
+
requireResponseSchema: boolean;
|
|
194
|
+
detectDeadCode: boolean;
|
|
195
|
+
}
|
|
196
|
+
interface CompilerConfig {
|
|
197
|
+
sourceDir: string;
|
|
198
|
+
outputDir: string;
|
|
199
|
+
entryFile: string;
|
|
200
|
+
schemas: SchemaConfig;
|
|
201
|
+
openapi: OpenAPIConfig;
|
|
202
|
+
validation: ValidationConfig;
|
|
203
|
+
}
|
|
204
|
+
interface VertzConfig {
|
|
205
|
+
strict?: boolean;
|
|
206
|
+
forceGenerate?: boolean;
|
|
207
|
+
compiler?: Partial<CompilerConfig>;
|
|
208
|
+
}
|
|
209
|
+
interface ResolvedConfig {
|
|
210
|
+
strict: boolean;
|
|
211
|
+
forceGenerate: boolean;
|
|
212
|
+
compiler: CompilerConfig;
|
|
213
|
+
}
|
|
214
|
+
declare function defineConfig(config: VertzConfig): VertzConfig;
|
|
215
|
+
declare function resolveConfig(config?: VertzConfig): ResolvedConfig;
|
|
216
|
+
interface Analyzer<T> {
|
|
217
|
+
analyze(): Promise<T>;
|
|
218
|
+
}
|
|
219
|
+
declare abstract class BaseAnalyzer<T> implements Analyzer<T> {
|
|
220
|
+
protected readonly project: Project;
|
|
221
|
+
protected readonly config: ResolvedConfig;
|
|
222
|
+
private readonly _diagnostics;
|
|
223
|
+
constructor(project: Project, config: ResolvedConfig);
|
|
224
|
+
protected addDiagnostic(diagnostic: Diagnostic): void;
|
|
225
|
+
getDiagnostics(): Diagnostic[];
|
|
226
|
+
}
|
|
227
|
+
interface AppAnalyzerResult {
|
|
228
|
+
app: AppDefinition;
|
|
229
|
+
}
|
|
230
|
+
declare class AppAnalyzer extends BaseAnalyzer<AppAnalyzerResult> {
|
|
231
|
+
analyze(): Promise<AppAnalyzerResult>;
|
|
232
|
+
private collectChainedCalls;
|
|
233
|
+
private extractMiddlewares;
|
|
234
|
+
private extractRegistrations;
|
|
235
|
+
private extractOptions;
|
|
236
|
+
}
|
|
237
|
+
interface DependencyGraphInput {
|
|
238
|
+
modules: ModuleIR[];
|
|
239
|
+
middleware: MiddlewareIR[];
|
|
240
|
+
}
|
|
241
|
+
interface DependencyGraphResult {
|
|
242
|
+
graph: DependencyGraphIR;
|
|
243
|
+
}
|
|
244
|
+
declare class DependencyGraphAnalyzer extends BaseAnalyzer<DependencyGraphResult> {
|
|
245
|
+
private input;
|
|
246
|
+
setInput(input: DependencyGraphInput): void;
|
|
247
|
+
analyze(input?: DependencyGraphInput): Promise<DependencyGraphResult>;
|
|
248
|
+
private buildNodes;
|
|
249
|
+
private buildServiceTokenMap;
|
|
250
|
+
private buildEdges;
|
|
251
|
+
private addInjectEdges;
|
|
252
|
+
private computeModuleOrder;
|
|
253
|
+
private detectCycles;
|
|
254
|
+
private emitCycleDiagnostics;
|
|
255
|
+
private emitUnresolvedInjectDiagnostics;
|
|
256
|
+
private warnUnresolvedInjects;
|
|
257
|
+
}
|
|
258
|
+
interface EnvAnalyzerResult {
|
|
259
|
+
env: EnvIR | undefined;
|
|
260
|
+
}
|
|
261
|
+
declare class EnvAnalyzer extends BaseAnalyzer<EnvAnalyzerResult> {
|
|
262
|
+
analyze(): Promise<EnvAnalyzerResult>;
|
|
263
|
+
}
|
|
264
|
+
interface MiddlewareAnalyzerResult {
|
|
265
|
+
middleware: MiddlewareIR[];
|
|
266
|
+
}
|
|
267
|
+
declare class MiddlewareAnalyzer extends BaseAnalyzer<MiddlewareAnalyzerResult> {
|
|
268
|
+
analyze(): Promise<MiddlewareAnalyzerResult>;
|
|
269
|
+
private resolveSchemaRef;
|
|
270
|
+
}
|
|
271
|
+
import { Expression, ObjectLiteralExpression } from "ts-morph";
|
|
272
|
+
interface ModuleAnalyzerResult {
|
|
273
|
+
modules: ModuleIR[];
|
|
274
|
+
}
|
|
275
|
+
declare class ModuleAnalyzer extends BaseAnalyzer<ModuleAnalyzerResult> {
|
|
276
|
+
analyze(): Promise<ModuleAnalyzerResult>;
|
|
277
|
+
}
|
|
278
|
+
declare function parseImports(obj: ObjectLiteralExpression): ImportRef[];
|
|
279
|
+
declare function extractIdentifierNames(expr: Expression): string[];
|
|
280
|
+
interface RouteAnalyzerResult {
|
|
281
|
+
routers: RouterIR[];
|
|
282
|
+
}
|
|
283
|
+
declare class RouteAnalyzer extends BaseAnalyzer<RouteAnalyzerResult> {
|
|
284
|
+
analyze(): Promise<RouteAnalyzerResult>;
|
|
285
|
+
analyzeForModules(context: ModuleDefContext): Promise<RouteAnalyzerResult>;
|
|
286
|
+
private detectUnknownRouterCalls;
|
|
287
|
+
private extractRoutes;
|
|
288
|
+
private findChainedHttpCalls;
|
|
289
|
+
private chainResolvesToVariable;
|
|
290
|
+
private extractRoute;
|
|
291
|
+
private resolveSchemaRef;
|
|
292
|
+
private extractMiddlewareRefs;
|
|
293
|
+
private generateOperationId;
|
|
294
|
+
}
|
|
295
|
+
import { Expression as Expression2, SourceFile } from "ts-morph";
|
|
296
|
+
interface SchemaAnalyzerResult {
|
|
297
|
+
schemas: SchemaIR[];
|
|
298
|
+
}
|
|
299
|
+
declare class SchemaAnalyzer extends BaseAnalyzer<SchemaAnalyzerResult> {
|
|
300
|
+
analyze(): Promise<SchemaAnalyzerResult>;
|
|
301
|
+
}
|
|
302
|
+
declare function parseSchemaName2(name: string): SchemaNameParts;
|
|
303
|
+
declare function isSchemaExpression(_file: SourceFile, expr: Expression2): boolean;
|
|
304
|
+
declare function extractSchemaId(expr: Expression2): string | null;
|
|
305
|
+
declare function isSchemaFile(file: SourceFile): boolean;
|
|
306
|
+
declare function createNamedSchemaRef(schemaName: string, sourceFile: string): NamedSchemaRef;
|
|
307
|
+
declare function createInlineSchemaRef(sourceFile: string): InlineSchemaRef;
|
|
308
|
+
import { Expression as Expression3, ObjectLiteralExpression as ObjectLiteralExpression2 } from "ts-morph";
|
|
309
|
+
interface ServiceAnalyzerResult {
|
|
310
|
+
services: ServiceIR[];
|
|
311
|
+
}
|
|
312
|
+
declare class ServiceAnalyzer extends BaseAnalyzer<ServiceAnalyzerResult> {
|
|
313
|
+
analyze(): Promise<ServiceAnalyzerResult>;
|
|
314
|
+
analyzeForModule(moduleDefVarName: string, moduleName: string): Promise<ServiceIR[]>;
|
|
315
|
+
}
|
|
316
|
+
declare function parseInjectRefs(obj: ObjectLiteralExpression2): InjectRef[];
|
|
317
|
+
declare function extractMethodSignatures(expr: Expression3): ServiceMethodIR[];
|
|
318
|
+
interface Generator {
|
|
319
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
320
|
+
}
|
|
321
|
+
declare abstract class BaseGenerator implements Generator {
|
|
322
|
+
protected readonly config: ResolvedConfig;
|
|
323
|
+
constructor(config: ResolvedConfig);
|
|
324
|
+
protected resolveOutputPath(outputDir: string, fileName: string): string;
|
|
325
|
+
}
|
|
326
|
+
interface Validator {
|
|
327
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
328
|
+
}
|
|
329
|
+
interface CompileResult {
|
|
330
|
+
success: boolean;
|
|
331
|
+
ir: AppIR;
|
|
332
|
+
diagnostics: Diagnostic[];
|
|
333
|
+
}
|
|
334
|
+
interface CompilerDependencies {
|
|
335
|
+
analyzers: {
|
|
336
|
+
env: Analyzer<EnvAnalyzerResult>;
|
|
337
|
+
schema: Analyzer<SchemaAnalyzerResult>;
|
|
338
|
+
middleware: Analyzer<MiddlewareAnalyzerResult>;
|
|
339
|
+
module: Analyzer<ModuleAnalyzerResult>;
|
|
340
|
+
app: Analyzer<AppAnalyzerResult>;
|
|
341
|
+
dependencyGraph: Analyzer<DependencyGraphResult>;
|
|
342
|
+
};
|
|
343
|
+
validators: Validator[];
|
|
344
|
+
generators: Generator[];
|
|
345
|
+
}
|
|
346
|
+
declare class Compiler {
|
|
347
|
+
private readonly config;
|
|
348
|
+
private readonly deps;
|
|
349
|
+
constructor(config: ResolvedConfig, dependencies: CompilerDependencies);
|
|
350
|
+
getConfig(): ResolvedConfig;
|
|
351
|
+
analyze(): Promise<AppIR>;
|
|
352
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
353
|
+
generate(ir: AppIR): Promise<void>;
|
|
354
|
+
compile(): Promise<CompileResult>;
|
|
355
|
+
}
|
|
356
|
+
declare function createCompiler(config?: VertzConfig): Compiler;
|
|
357
|
+
interface BootModuleEntry {
|
|
358
|
+
name: string;
|
|
359
|
+
importPath: string;
|
|
360
|
+
variableName: string;
|
|
361
|
+
options?: Record<string, unknown>;
|
|
362
|
+
}
|
|
363
|
+
interface BootMiddlewareEntry {
|
|
364
|
+
name: string;
|
|
365
|
+
importPath: string;
|
|
366
|
+
variableName: string;
|
|
367
|
+
}
|
|
368
|
+
interface BootManifest {
|
|
369
|
+
initializationOrder: string[];
|
|
370
|
+
modules: BootModuleEntry[];
|
|
371
|
+
globalMiddleware: BootMiddlewareEntry[];
|
|
372
|
+
}
|
|
373
|
+
declare function buildBootManifest(ir: AppIR): BootManifest;
|
|
374
|
+
declare function resolveImportPath(from: string, to: string): string;
|
|
375
|
+
declare function renderBootFile(manifest: BootManifest, outputDir: string): string;
|
|
376
|
+
declare class BootGenerator extends BaseGenerator {
|
|
377
|
+
readonly name = "boot";
|
|
378
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
379
|
+
}
|
|
380
|
+
interface ManifestModule {
|
|
381
|
+
name: string;
|
|
382
|
+
services: string[];
|
|
383
|
+
routers: string[];
|
|
384
|
+
exports: string[];
|
|
385
|
+
imports: {
|
|
386
|
+
from: string;
|
|
387
|
+
items: string[];
|
|
388
|
+
}[];
|
|
389
|
+
}
|
|
390
|
+
interface ManifestRoute {
|
|
391
|
+
method: HttpMethod;
|
|
392
|
+
path: string;
|
|
393
|
+
operationId: string;
|
|
394
|
+
module: string;
|
|
395
|
+
router: string;
|
|
396
|
+
middleware: string[];
|
|
397
|
+
params?: Record<string, unknown>;
|
|
398
|
+
query?: Record<string, unknown>;
|
|
399
|
+
body?: Record<string, unknown>;
|
|
400
|
+
headers?: Record<string, unknown>;
|
|
401
|
+
response?: Record<string, unknown>;
|
|
402
|
+
}
|
|
403
|
+
interface ManifestMiddleware {
|
|
404
|
+
name: string;
|
|
405
|
+
provides?: Record<string, unknown>;
|
|
406
|
+
requires?: Record<string, unknown>;
|
|
407
|
+
}
|
|
408
|
+
interface ManifestDependencyEdge {
|
|
409
|
+
from: string;
|
|
410
|
+
to: string;
|
|
411
|
+
type: DependencyEdgeKind;
|
|
412
|
+
}
|
|
413
|
+
interface ManifestDiagnostic {
|
|
414
|
+
severity: "error" | "warning" | "info";
|
|
415
|
+
code: string;
|
|
416
|
+
message: string;
|
|
417
|
+
file?: string;
|
|
418
|
+
line?: number;
|
|
419
|
+
suggestion?: string;
|
|
420
|
+
}
|
|
421
|
+
interface AppManifest {
|
|
422
|
+
version: string;
|
|
423
|
+
app: {
|
|
424
|
+
basePath: string;
|
|
425
|
+
version?: string;
|
|
426
|
+
};
|
|
427
|
+
modules: ManifestModule[];
|
|
428
|
+
routes: ManifestRoute[];
|
|
429
|
+
schemas: Record<string, Record<string, unknown>>;
|
|
430
|
+
middleware: ManifestMiddleware[];
|
|
431
|
+
dependencyGraph: {
|
|
432
|
+
initializationOrder: string[];
|
|
433
|
+
edges: ManifestDependencyEdge[];
|
|
434
|
+
};
|
|
435
|
+
diagnostics: {
|
|
436
|
+
errors: number;
|
|
437
|
+
warnings: number;
|
|
438
|
+
items: ManifestDiagnostic[];
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
declare function buildManifest(ir: AppIR): AppManifest;
|
|
442
|
+
declare class ManifestGenerator extends BaseGenerator {
|
|
443
|
+
readonly name = "manifest";
|
|
444
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
445
|
+
}
|
|
446
|
+
interface OpenAPIDocument {
|
|
447
|
+
openapi: "3.1.0";
|
|
448
|
+
info: OpenAPIInfo;
|
|
449
|
+
servers: OpenAPIServer[];
|
|
450
|
+
paths: Record<string, OpenAPIPathItem>;
|
|
451
|
+
components: {
|
|
452
|
+
schemas: Record<string, JSONSchemaObject>;
|
|
453
|
+
};
|
|
454
|
+
tags: OpenAPITag[];
|
|
455
|
+
}
|
|
456
|
+
interface OpenAPIInfo {
|
|
457
|
+
title: string;
|
|
458
|
+
version: string;
|
|
459
|
+
description?: string;
|
|
460
|
+
}
|
|
461
|
+
interface OpenAPIServer {
|
|
462
|
+
url: string;
|
|
463
|
+
description?: string;
|
|
464
|
+
}
|
|
465
|
+
interface OpenAPITag {
|
|
466
|
+
name: string;
|
|
467
|
+
description?: string;
|
|
468
|
+
}
|
|
469
|
+
interface OpenAPIPathItem {
|
|
470
|
+
[method: string]: OpenAPIOperation | undefined;
|
|
471
|
+
get?: OpenAPIOperation;
|
|
472
|
+
post?: OpenAPIOperation;
|
|
473
|
+
put?: OpenAPIOperation;
|
|
474
|
+
delete?: OpenAPIOperation;
|
|
475
|
+
patch?: OpenAPIOperation;
|
|
476
|
+
head?: OpenAPIOperation;
|
|
477
|
+
options?: OpenAPIOperation;
|
|
478
|
+
}
|
|
479
|
+
interface OpenAPIOperation {
|
|
480
|
+
operationId: string;
|
|
481
|
+
summary?: string;
|
|
482
|
+
description?: string;
|
|
483
|
+
tags: string[];
|
|
484
|
+
parameters: OpenAPIParameter[];
|
|
485
|
+
requestBody?: OpenAPIRequestBody;
|
|
486
|
+
responses: Record<string, OpenAPIResponse>;
|
|
487
|
+
}
|
|
488
|
+
interface OpenAPIParameter {
|
|
489
|
+
name: string;
|
|
490
|
+
in: "path" | "query" | "header";
|
|
491
|
+
required: boolean;
|
|
492
|
+
schema: JSONSchemaObject;
|
|
493
|
+
description?: string;
|
|
494
|
+
}
|
|
495
|
+
interface OpenAPIRequestBody {
|
|
496
|
+
required: boolean;
|
|
497
|
+
content: {
|
|
498
|
+
"application/json": {
|
|
499
|
+
schema: JSONSchemaObject;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
interface OpenAPIResponse {
|
|
504
|
+
description: string;
|
|
505
|
+
content?: {
|
|
506
|
+
"application/json": {
|
|
507
|
+
schema: JSONSchemaObject;
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
type JSONSchemaObject = {
|
|
512
|
+
$ref?: string;
|
|
513
|
+
type?: string | string[];
|
|
514
|
+
properties?: Record<string, JSONSchemaObject>;
|
|
515
|
+
required?: string[];
|
|
516
|
+
items?: JSONSchemaObject;
|
|
517
|
+
oneOf?: JSONSchemaObject[];
|
|
518
|
+
allOf?: JSONSchemaObject[];
|
|
519
|
+
anyOf?: JSONSchemaObject[];
|
|
520
|
+
discriminator?: {
|
|
521
|
+
propertyName: string;
|
|
522
|
+
mapping?: Record<string, string>;
|
|
523
|
+
};
|
|
524
|
+
enum?: (string | number | boolean | null)[];
|
|
525
|
+
const?: string | number | boolean | null;
|
|
526
|
+
format?: string;
|
|
527
|
+
description?: string;
|
|
528
|
+
default?: unknown;
|
|
529
|
+
$defs?: Record<string, JSONSchemaObject>;
|
|
530
|
+
additionalProperties?: boolean | JSONSchemaObject;
|
|
531
|
+
[key: string]: unknown;
|
|
532
|
+
};
|
|
533
|
+
declare class OpenAPIGenerator extends BaseGenerator {
|
|
534
|
+
readonly name = "openapi";
|
|
535
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
536
|
+
buildDocument(ir: AppIR): OpenAPIDocument;
|
|
537
|
+
private buildOperation;
|
|
538
|
+
private buildResponses;
|
|
539
|
+
private resolveAndLift;
|
|
540
|
+
private getSuccessStatusCode;
|
|
541
|
+
convertPath(routePath: string): string;
|
|
542
|
+
buildParameters(route: RouteIR, middlewareMap: Map<string, MiddlewareIR>): OpenAPIParameter[];
|
|
543
|
+
resolveSchemaRef(schemaRef: SchemaRef): JSONSchemaObject;
|
|
544
|
+
private extractParamsFromSchema;
|
|
545
|
+
private extractHeaderParams;
|
|
546
|
+
liftDefsToComponents(schema: JSONSchemaObject, components: Record<string, JSONSchemaObject>): JSONSchemaObject;
|
|
547
|
+
private rewriteRefs;
|
|
548
|
+
collectTags(ir: AppIR): OpenAPITag[];
|
|
549
|
+
}
|
|
550
|
+
interface RouteTableSchemas {
|
|
551
|
+
params?: string;
|
|
552
|
+
query?: string;
|
|
553
|
+
body?: string;
|
|
554
|
+
headers?: string;
|
|
555
|
+
response?: string;
|
|
556
|
+
}
|
|
557
|
+
interface RouteTableEntry {
|
|
558
|
+
method: HttpMethod;
|
|
559
|
+
path: string;
|
|
560
|
+
operationId: string;
|
|
561
|
+
moduleName: string;
|
|
562
|
+
routerName: string;
|
|
563
|
+
middleware: string[];
|
|
564
|
+
schemas: RouteTableSchemas;
|
|
565
|
+
}
|
|
566
|
+
interface RouteTableManifest {
|
|
567
|
+
routes: RouteTableEntry[];
|
|
568
|
+
}
|
|
569
|
+
declare function buildRouteTable(ir: AppIR): RouteTableManifest;
|
|
570
|
+
declare function renderRouteTableFile(manifest: RouteTableManifest): string;
|
|
571
|
+
declare class RouteTableGenerator extends BaseGenerator {
|
|
572
|
+
readonly name = "route-table";
|
|
573
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
574
|
+
}
|
|
575
|
+
interface SchemaRegistryEntry {
|
|
576
|
+
name: string;
|
|
577
|
+
id?: string;
|
|
578
|
+
importPath: string;
|
|
579
|
+
variableName: string;
|
|
580
|
+
jsonSchema?: Record<string, unknown>;
|
|
581
|
+
}
|
|
582
|
+
interface SchemaRegistryManifest {
|
|
583
|
+
schemas: SchemaRegistryEntry[];
|
|
584
|
+
}
|
|
585
|
+
declare function buildSchemaRegistry(ir: AppIR): SchemaRegistryManifest;
|
|
586
|
+
declare function renderSchemaRegistryFile(manifest: SchemaRegistryManifest, outputDir: string): string;
|
|
587
|
+
declare class SchemaRegistryGenerator extends BaseGenerator {
|
|
588
|
+
readonly name = "schema-registry";
|
|
589
|
+
generate(ir: AppIR, outputDir: string): Promise<void>;
|
|
590
|
+
}
|
|
591
|
+
interface FileChange {
|
|
592
|
+
path: string;
|
|
593
|
+
kind: "added" | "modified" | "deleted";
|
|
594
|
+
}
|
|
595
|
+
type FileCategory = "schema" | "router" | "service" | "module" | "middleware" | "app-entry" | "env" | "config";
|
|
596
|
+
interface CategorizedChanges {
|
|
597
|
+
schema: FileChange[];
|
|
598
|
+
router: FileChange[];
|
|
599
|
+
service: FileChange[];
|
|
600
|
+
module: FileChange[];
|
|
601
|
+
middleware: FileChange[];
|
|
602
|
+
requiresFullRecompile: boolean;
|
|
603
|
+
requiresReboot: boolean;
|
|
604
|
+
rebootReason?: string;
|
|
605
|
+
}
|
|
606
|
+
interface CategorizeOptions {
|
|
607
|
+
entryFile?: string;
|
|
608
|
+
}
|
|
609
|
+
declare function categorizeChanges(changes: FileChange[], options?: CategorizeOptions): CategorizedChanges;
|
|
610
|
+
declare function findAffectedModules(categorized: CategorizedChanges, ir: AppIR): string[];
|
|
611
|
+
type IncrementalResult = {
|
|
612
|
+
kind: "incremental";
|
|
613
|
+
affectedModules: string[];
|
|
614
|
+
diagnostics: Diagnostic[];
|
|
615
|
+
} | {
|
|
616
|
+
kind: "full-recompile";
|
|
617
|
+
} | {
|
|
618
|
+
kind: "reboot";
|
|
619
|
+
reason: string;
|
|
620
|
+
};
|
|
621
|
+
declare class IncrementalCompiler {
|
|
622
|
+
private currentIR;
|
|
623
|
+
private readonly compiler;
|
|
624
|
+
constructor(compiler: Compiler);
|
|
625
|
+
initialCompile(): Promise<CompileResult>;
|
|
626
|
+
handleChanges(changes: FileChange[]): Promise<IncrementalResult>;
|
|
627
|
+
getCurrentIR(): AppIR;
|
|
628
|
+
}
|
|
629
|
+
declare function createEmptyDependencyGraph(): DependencyGraphIR;
|
|
630
|
+
declare function createEmptyAppIR(): AppIR;
|
|
631
|
+
declare function addDiagnosticsToIR(ir: AppIR, diagnostics: readonly Diagnostic[]): AppIR;
|
|
632
|
+
declare function mergeIR(base: AppIR, partial: Partial<AppIR>): AppIR;
|
|
633
|
+
import { ChildProcess } from "node:child_process";
|
|
634
|
+
interface TypecheckDiagnostic {
|
|
635
|
+
file: string;
|
|
636
|
+
line: number;
|
|
637
|
+
column: number;
|
|
638
|
+
message: string;
|
|
639
|
+
code: number;
|
|
640
|
+
}
|
|
641
|
+
interface TypecheckResult {
|
|
642
|
+
success: boolean;
|
|
643
|
+
diagnostics: TypecheckDiagnostic[];
|
|
644
|
+
}
|
|
645
|
+
interface TypecheckOptions {
|
|
646
|
+
tsconfigPath?: string;
|
|
647
|
+
}
|
|
648
|
+
declare function parseTscOutput(output: string): TypecheckDiagnostic[];
|
|
649
|
+
declare function parseWatchBlock(block: string): TypecheckResult;
|
|
650
|
+
interface TypecheckWatchOptions extends TypecheckOptions {
|
|
651
|
+
spawner?: () => ChildProcess;
|
|
652
|
+
}
|
|
653
|
+
declare function typecheckWatch(options?: TypecheckWatchOptions): AsyncGenerator<TypecheckResult>;
|
|
654
|
+
declare function typecheck(options?: TypecheckOptions): Promise<TypecheckResult>;
|
|
655
|
+
import { CallExpression, Expression as Expression4, Node, ObjectLiteralExpression as ObjectLiteralExpression3, SourceFile as SourceFile2 } from "ts-morph";
|
|
656
|
+
declare function findCallExpressions(file: SourceFile2, objectName: string, methodName: string): CallExpression[];
|
|
657
|
+
declare function findMethodCallsOnVariable(file: SourceFile2, variableName: string, methodName: string): CallExpression[];
|
|
658
|
+
declare function extractObjectLiteral(callExpr: CallExpression, argIndex: number): ObjectLiteralExpression3 | null;
|
|
659
|
+
declare function getPropertyValue(obj: ObjectLiteralExpression3, key: string): Expression4 | null;
|
|
660
|
+
declare function getProperties(obj: ObjectLiteralExpression3): {
|
|
661
|
+
name: string;
|
|
662
|
+
value: Expression4;
|
|
663
|
+
}[];
|
|
664
|
+
declare function getStringValue(expr: Expression4): string | null;
|
|
665
|
+
declare function getBooleanValue(expr: Expression4): boolean | null;
|
|
666
|
+
declare function getNumberValue(expr: Expression4): number | null;
|
|
667
|
+
declare function getArrayElements(expr: Expression4): Expression4[];
|
|
668
|
+
declare function getVariableNameForCall(callExpr: CallExpression): string | null;
|
|
669
|
+
declare function getSourceLocation(node: Node): SourceLocation;
|
|
670
|
+
import { Identifier, Node as Node2, Project as Project2, SourceFile as SourceFile3 } from "ts-morph";
|
|
671
|
+
interface ResolvedImport {
|
|
672
|
+
declaration: Node2;
|
|
673
|
+
sourceFile: SourceFile3;
|
|
674
|
+
exportName: string;
|
|
675
|
+
}
|
|
676
|
+
declare function resolveIdentifier(identifier: Identifier, project: Project2): ResolvedImport | null;
|
|
677
|
+
declare function resolveExport(file: SourceFile3, exportName: string, project: Project2): ResolvedImport | null;
|
|
678
|
+
declare function isFromImport(identifier: Identifier, moduleSpecifier: string): boolean;
|
|
679
|
+
interface SchemaExecutionResult {
|
|
680
|
+
jsonSchema: Record<string, unknown>;
|
|
681
|
+
}
|
|
682
|
+
interface SchemaExecutor {
|
|
683
|
+
execute(schemaName: string, sourceFile: string): Promise<SchemaExecutionResult | null>;
|
|
684
|
+
getDiagnostics(): Diagnostic[];
|
|
685
|
+
}
|
|
686
|
+
declare function createSchemaExecutor(_rootDir: string): SchemaExecutor;
|
|
687
|
+
declare class CompletenessValidator implements Validator {
|
|
688
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
689
|
+
private checkResponseSchemas;
|
|
690
|
+
private checkUnusedServices;
|
|
691
|
+
private checkUnreferencedSchemas;
|
|
692
|
+
private checkDIWiring;
|
|
693
|
+
private checkInjectTokens;
|
|
694
|
+
private checkMiddlewareChains;
|
|
695
|
+
private checkModuleOptions;
|
|
696
|
+
private checkRoutePathFormat;
|
|
697
|
+
private checkPathParamMatch;
|
|
698
|
+
private checkDuplicateRoutes;
|
|
699
|
+
private checkCtxKeyCollisions;
|
|
700
|
+
}
|
|
701
|
+
declare class ModuleValidator implements Validator {
|
|
702
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
703
|
+
private checkExports;
|
|
704
|
+
private checkOwnership;
|
|
705
|
+
private checkCircularDependencies;
|
|
706
|
+
}
|
|
707
|
+
interface ParsedSchemaName {
|
|
708
|
+
operation: string | null;
|
|
709
|
+
entity: string | null;
|
|
710
|
+
part: string | null;
|
|
711
|
+
}
|
|
712
|
+
type ValidOperation = "create" | "read" | "update" | "list" | "delete";
|
|
713
|
+
type ValidPart = "Body" | "Response" | "Query" | "Params" | "Headers";
|
|
714
|
+
declare class NamingValidator implements Validator {
|
|
715
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
716
|
+
parseSchemaName(name: string): ParsedSchemaName;
|
|
717
|
+
private suggestFix;
|
|
718
|
+
}
|
|
719
|
+
declare class PlacementValidator implements Validator {
|
|
720
|
+
validate(ir: AppIR): Promise<Diagnostic[]>;
|
|
721
|
+
private checkFileLocation;
|
|
722
|
+
private checkMixedExports;
|
|
723
|
+
}
|
|
724
|
+
export { typecheckWatch, typecheck, resolveImportPath, resolveIdentifier, resolveExport, resolveConfig, renderSchemaRegistryFile, renderRouteTableFile, renderBootFile, parseWatchBlock, parseTscOutput, parseSchemaName2 as parseSchemaName, parseInjectRefs, parseImports, mergeIR, mergeDiagnostics, isSchemaFile, isSchemaExpression, isFromImport, hasErrors, getVariableNameForCall, getStringValue, getSourceLocation, getPropertyValue, getProperties, getNumberValue, getBooleanValue, getArrayElements, findMethodCallsOnVariable, findCallExpressions, findAffectedModules, filterBySeverity, extractSchemaId, extractObjectLiteral, extractMethodSignatures, extractIdentifierNames, defineConfig, createSchemaExecutor, createNamedSchemaRef, createInlineSchemaRef, createEmptyDependencyGraph, createEmptyAppIR, createDiagnosticFromLocation, createDiagnostic, createCompiler, categorizeChanges, buildSchemaRegistry, buildRouteTable, buildManifest, buildBootManifest, addDiagnosticsToIR, VertzConfig, Validator, ValidationConfig, ValidPart, ValidOperation, TypecheckWatchOptions, TypecheckResult, TypecheckOptions, TypecheckDiagnostic, SourceLocation, SourceContext, ServiceMethodParam, ServiceMethodIR, ServiceIR, ServiceAnalyzerResult, ServiceAnalyzer, SchemaRegistryManifest, SchemaRegistryGenerator, SchemaRegistryEntry, SchemaRef, SchemaNameParts, SchemaIR, SchemaExecutor, SchemaExecutionResult, SchemaConfig, SchemaAnalyzerResult, SchemaAnalyzer, RouterIR, RouteTableSchemas, RouteTableManifest, RouteTableGenerator, RouteTableEntry, RouteIR, RouteAnalyzerResult, RouteAnalyzer, ResolvedImport, ResolvedConfig, PlacementValidator, ParsedSchemaName, OpenAPITag, OpenAPIServer, OpenAPIResponse, OpenAPIRequestBody, OpenAPIPathItem, OpenAPIParameter, OpenAPIOperation, OpenAPIInfo, OpenAPIGenerator, OpenAPIDocument, OpenAPIConfig, NamingValidator, NamedSchemaRef, ModuleValidator, ModuleRegistration, ModuleIR, ModuleDefContext, ModuleAnalyzerResult, ModuleAnalyzer, MiddlewareRef, MiddlewareIR, MiddlewareAnalyzerResult, MiddlewareAnalyzer, ManifestRoute, ManifestModule, ManifestMiddleware, ManifestGenerator, ManifestDiagnostic, ManifestDependencyEdge, JSONSchemaObject, InlineSchemaRef, InjectRef, IncrementalResult, IncrementalCompiler, ImportRef, HttpMethod, Generator, FileChange, FileCategory, EnvVariableIR, EnvIR, EnvAnalyzerResult, EnvAnalyzer, DiagnosticSeverity, DiagnosticCode, Diagnostic, DependencyNodeKind, DependencyNode, DependencyGraphResult, DependencyGraphInput, DependencyGraphIR, DependencyGraphAnalyzer, DependencyEdgeKind, DependencyEdge, CreateDiagnosticOptions, CompletenessValidator, CompilerDependencies, CompilerConfig, Compiler, CompileResult, CategorizedChanges, CategorizeOptions, BootModuleEntry, BootMiddlewareEntry, BootManifest, BootGenerator, BaseGenerator, BaseAnalyzer, AppManifest, AppIR, AppDefinition, AppAnalyzerResult, AppAnalyzer, Analyzer };
|