@supacloud/compiler 0.3.1 → 0.4.1
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/analyze.d.ts +3 -3
- package/dist/cli.js +1698 -0
- package/dist/compile.d.ts +8 -3
- package/dist/generate.d.ts +8 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +377 -7
- package/dist/profiles.d.ts +36 -0
- package/dist/types.d.ts +79 -25
- package/dist/util.d.ts +7 -7
- package/dist/validate.d.ts +4 -7
- package/package.json +5 -2
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ApplicationGraph
|
|
3
|
-
*
|
|
2
|
+
* ApplicationGraph: Static application graph built by the compiler from source AST.
|
|
3
|
+
* No runtime reflection or container; all metadata is explicitly represented here and in generated code.
|
|
4
4
|
*/
|
|
5
5
|
export type Scope = "application" | "request" | "job";
|
|
6
6
|
export type ProviderKind = "class" | "value" | "factory" | "existing";
|
|
@@ -13,7 +13,7 @@ export interface Diagnostic {
|
|
|
13
13
|
line?: number;
|
|
14
14
|
}
|
|
15
15
|
export interface ProviderNode {
|
|
16
|
-
/**
|
|
16
|
+
/** Token name (InjectionToken variable name or class name). */
|
|
17
17
|
token: string;
|
|
18
18
|
tokenKind: TokenKind;
|
|
19
19
|
kind: ProviderKind;
|
|
@@ -22,16 +22,16 @@ export interface ProviderNode {
|
|
|
22
22
|
useFactoryName?: string;
|
|
23
23
|
useExisting?: string;
|
|
24
24
|
scope: Scope;
|
|
25
|
-
/**
|
|
25
|
+
/** Token names in constructor/factory parameter order. */
|
|
26
26
|
deps: string[];
|
|
27
27
|
exported: boolean;
|
|
28
28
|
file: string;
|
|
29
29
|
line: number;
|
|
30
|
-
/** useClass/useFactory/useValue
|
|
30
|
+
/** Relative module path of useClass/useFactory/useValue symbol (for import generation). */
|
|
31
31
|
importPath?: string;
|
|
32
32
|
}
|
|
33
33
|
export interface RouteNode {
|
|
34
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
34
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
35
35
|
path: string;
|
|
36
36
|
handler: string;
|
|
37
37
|
body?: string;
|
|
@@ -49,7 +49,7 @@ export interface ControllerNode {
|
|
|
49
49
|
routes: RouteNode[];
|
|
50
50
|
file: string;
|
|
51
51
|
importPath: string;
|
|
52
|
-
/**
|
|
52
|
+
/** Route schema symbol name -> relative module path (for import generation). */
|
|
53
53
|
schemaImports?: Record<string, string>;
|
|
54
54
|
}
|
|
55
55
|
export interface CommandNode {
|
|
@@ -65,60 +65,114 @@ export interface QueryNode {
|
|
|
65
65
|
name: string;
|
|
66
66
|
}
|
|
67
67
|
export interface ModuleNode {
|
|
68
|
-
/** @Module({ name })
|
|
68
|
+
/** Name from @Module({ name }) or defineModule. */
|
|
69
69
|
name: string;
|
|
70
70
|
className: string;
|
|
71
|
-
/**
|
|
71
|
+
/** Module tags (e.g. ['scope:case', 'type:feature']) for architecture boundary governance. */
|
|
72
72
|
tags?: string[];
|
|
73
73
|
file: string;
|
|
74
74
|
line: number;
|
|
75
|
-
/**
|
|
75
|
+
/** Names of imported modules. */
|
|
76
76
|
imports: string[];
|
|
77
77
|
providers: ProviderNode[];
|
|
78
78
|
controllers: ControllerNode[];
|
|
79
79
|
commands: CommandNode[];
|
|
80
80
|
queries: QueryNode[];
|
|
81
|
-
/**
|
|
81
|
+
/** Exported token names. */
|
|
82
82
|
exports: string[];
|
|
83
83
|
}
|
|
84
84
|
export interface ApplicationGraph {
|
|
85
85
|
modules: ModuleNode[];
|
|
86
|
-
/**
|
|
86
|
+
/** Depended token names provided by platform injection rather than any module. */
|
|
87
87
|
externalTokens: string[];
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
89
|
+
* Diagnostics produced during analysis (e.g. missing-deps), merged by compileProject.
|
|
90
|
+
* Omitted from app.manifest.json.
|
|
91
91
|
*/
|
|
92
92
|
diagnostics?: Diagnostic[];
|
|
93
93
|
/**
|
|
94
|
-
* InjectionToken
|
|
95
|
-
* "supacloud.request-context"
|
|
96
|
-
*
|
|
94
|
+
* InjectionToken variable name -> string name (e.g. REQUEST_CONTEXT ->
|
|
95
|
+
* "supacloud.request-context"), used during code generation to identify built-in context tokens.
|
|
96
|
+
* Omitted from app.manifest.json.
|
|
97
97
|
*/
|
|
98
98
|
tokenNames?: Record<string, string>;
|
|
99
99
|
}
|
|
100
100
|
export interface CompileOptions {
|
|
101
|
-
/**
|
|
101
|
+
/** Project root directory (containing tsconfig). */
|
|
102
102
|
rootDir: string;
|
|
103
|
-
/**
|
|
103
|
+
/** Glob patterns, defaults to ['**\/*.module.ts', '**\/*.ts']. */
|
|
104
104
|
include?: string[];
|
|
105
|
-
/**
|
|
105
|
+
/** Output directory (e.g. <rootDir>/generated). */
|
|
106
106
|
outDir: string;
|
|
107
|
-
/** warn
|
|
107
|
+
/** Upgrade warn-level diagnostics to error. */
|
|
108
108
|
strict?: boolean;
|
|
109
|
-
/**
|
|
109
|
+
/** Built-in architecture boundary preset (for example, 'modular-monolith'). */
|
|
110
|
+
moduleBoundaryPreset?: ModuleBoundaryPresetName;
|
|
111
|
+
/** Module boundary and architecture governance rules inspired by Nx enforce-module-boundaries. */
|
|
110
112
|
moduleBoundaries?: ModuleBoundaryRule[];
|
|
113
|
+
/** Allow routes to bind directly to @Command (defaults to true). */
|
|
114
|
+
allowRouteCommandBindings?: boolean;
|
|
115
|
+
/** Runtime Command executor capabilities used to validate declared governance metadata. */
|
|
116
|
+
commandCapabilities?: CommandExecutionCapabilities;
|
|
117
|
+
/** Disallow controllers from directly injecting DB clients (enforces presentation layer separation). */
|
|
118
|
+
disallowControllerDirectDb?: boolean;
|
|
119
|
+
/** Detect modules declared in the project that are unreachable from any root module. */
|
|
120
|
+
detectOrphanModules?: boolean;
|
|
111
121
|
}
|
|
112
122
|
export interface ModuleBoundaryRule {
|
|
113
|
-
/**
|
|
123
|
+
/** Source module tag pattern or tag (for example, 'type:ui', 'scope:case', or '*'). */
|
|
114
124
|
sourceTag: string;
|
|
115
|
-
/**
|
|
125
|
+
/** Tags allowed for modules imported by the source module. */
|
|
116
126
|
onlyDependOnLibsWithTags?: string[];
|
|
117
|
-
/**
|
|
127
|
+
/** Tags forbidden for modules imported by the source module. */
|
|
118
128
|
bannedDependenciesWithTags?: string[];
|
|
119
129
|
}
|
|
130
|
+
/** Names of built-in module boundary presets. */
|
|
131
|
+
export type ModuleBoundaryPresetName = "modular-monolith" | "feature-slices" | "vertical-slices" | "angular-enterprise" | "angular" | "clean-architecture" | "domain-driven";
|
|
132
|
+
export interface ModuleBoundaryProfile {
|
|
133
|
+
name: ModuleBoundaryPresetName;
|
|
134
|
+
description: string;
|
|
135
|
+
rules: ModuleBoundaryRule[];
|
|
136
|
+
}
|
|
137
|
+
export interface ValidateOptions {
|
|
138
|
+
strict?: boolean;
|
|
139
|
+
moduleBoundaryPreset?: ModuleBoundaryPresetName;
|
|
140
|
+
moduleBoundaries?: ModuleBoundaryRule[];
|
|
141
|
+
/** Allow routes to bind directly to @Command (defaults to true). */
|
|
142
|
+
allowRouteCommandBindings?: boolean;
|
|
143
|
+
/** Runtime Command executor capabilities used to validate declared governance metadata. */
|
|
144
|
+
commandCapabilities?: CommandExecutionCapabilities;
|
|
145
|
+
/** Disallow controllers from directly injecting DB clients. */
|
|
146
|
+
disallowControllerDirectDb?: boolean;
|
|
147
|
+
/** Detect modules declared in the project that are unreachable from any root module. */
|
|
148
|
+
detectOrphanModules?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** Runtime capabilities declared by the Command executor. */
|
|
151
|
+
export interface CommandExecutionCapabilities {
|
|
152
|
+
/** Whether runtime permission checks are supported. */
|
|
153
|
+
permission?: boolean;
|
|
154
|
+
/** Whether runtime audit persistence is supported. */
|
|
155
|
+
audit?: boolean;
|
|
156
|
+
/** Whether idempotency receipts are supported. */
|
|
157
|
+
idempotency?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Transaction execution capability:
|
|
160
|
+
* - true: full transaction boundaries are supported;
|
|
161
|
+
* - 'rpc-only': application-level transactions are unavailable and multi-table writes must use one DB RPC (warn);
|
|
162
|
+
* - false: transaction support is disabled (error).
|
|
163
|
+
*/
|
|
164
|
+
transaction?: boolean | "rpc-only";
|
|
165
|
+
}
|
|
120
166
|
export interface CompileResult {
|
|
121
167
|
diagnostics: Diagnostic[];
|
|
122
168
|
graph: ApplicationGraph;
|
|
123
169
|
written: string[];
|
|
124
170
|
}
|
|
171
|
+
export interface CheckProjectResult {
|
|
172
|
+
/** Whether generated artifacts exactly match the files on disk. */
|
|
173
|
+
upToDate: boolean;
|
|
174
|
+
/** Relative paths of missing or mismatched artifacts. */
|
|
175
|
+
mismatches: string[];
|
|
176
|
+
diagnostics: Diagnostic[];
|
|
177
|
+
graph: ApplicationGraph;
|
|
178
|
+
}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* CASE_REPOSITORY
|
|
4
|
-
* CaseService
|
|
2
|
+
* Token name -> key in services object.
|
|
3
|
+
* CASE_REPOSITORY -> caseRepository, LOGGER -> logger (convert CONSTANT_CASE to camelCase),
|
|
4
|
+
* CaseService -> caseService (lowercase first letter of PascalCase).
|
|
5
5
|
*/
|
|
6
6
|
export declare function camelName(token: string): string;
|
|
7
|
-
/**
|
|
7
|
+
/** Computes relative import path from fromDir to toFile (stripping extension, ensuring ./ or ../ prefix). */
|
|
8
8
|
export declare function relativeImportPath(fromDir: string, toFile: string): string;
|
|
9
|
-
/**
|
|
9
|
+
/** String names of built-in context tokens (aligned with REQUEST_CONTEXT/JOB_CONTEXT in @supacloud/app). */
|
|
10
10
|
export declare const REQUEST_CONTEXT_TOKEN_NAME = "supacloud.request-context";
|
|
11
11
|
export declare const JOB_CONTEXT_TOKEN_NAME = "supacloud.job-context";
|
|
12
|
-
/**
|
|
12
|
+
/** Determines whether token is built-in request context (variable name REQUEST_CONTEXT or matching token name). */
|
|
13
13
|
export declare function isRequestContextToken(token: string, tokenNames?: Record<string, string>): boolean;
|
|
14
|
-
/**
|
|
14
|
+
/** Determines whether token is built-in job context. */
|
|
15
15
|
export declare function isJobContextToken(token: string, tokenNames?: Record<string, string>): boolean;
|
package/dist/validate.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { ApplicationGraph, Diagnostic,
|
|
1
|
+
import type { ApplicationGraph, Diagnostic, ValidateOptions } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* strict
|
|
3
|
+
* Validates ApplicationGraph and produces diagnostics list.
|
|
4
|
+
* In strict mode, warn-level diagnostics are promoted to error.
|
|
5
5
|
*/
|
|
6
|
-
export declare function validateGraph(graph: ApplicationGraph, options?: boolean |
|
|
7
|
-
strict?: boolean;
|
|
8
|
-
moduleBoundaries?: ModuleBoundaryRule[];
|
|
9
|
-
}): Diagnostic[];
|
|
6
|
+
export declare function validateGraph(graph: ApplicationGraph, options?: boolean | ValidateOptions): Diagnostic[];
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"supacloud-compiler": "./dist/cli.js"
|
|
11
|
+
},
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
14
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "bun run clean && bun run build:js && bun run build:types",
|
|
22
|
-
"build:js": "bun build src/index.ts --outdir dist --target node --external ts-morph",
|
|
25
|
+
"build:js": "bun build src/index.ts src/cli.ts --outdir dist --target node --external ts-morph",
|
|
23
26
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
|
|
24
27
|
"clean": "rm -rf dist",
|
|
25
28
|
"prepublishOnly": "bun run build",
|