@supacloud/compiler 0.4.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ApplicationGraph } from "./types";
2
2
  /**
3
- * 分析 rootDir 下的源码(ts-morph AST,无类型检查依赖),构建 ApplicationGraph。
4
- * 装饰器仅按名字匹配(Module/Injectable/Inject/Command/Query/Controller/Get/...),
5
- * 不校验 import 来源,因此本包不需要依赖 @supacloud/app。
3
+ * Analyzes source code under rootDir (via ts-morph AST, without typecheck dependency) to build ApplicationGraph.
4
+ * Decorators are matched by name only (Module/Injectable/Inject/Command/Query/Controller/Get/...),
5
+ * without checking import origins, so this package does not need to depend on @supacloud/app.
6
6
  */
7
7
  export declare function analyzeProject(rootDir: string, include?: string[]): Promise<ApplicationGraph>;
package/dist/compile.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { CheckProjectResult, CompileOptions, CompileResult } from "./types";
2
2
  /**
3
- * 完整编译流程:AST 分析 → 校验 → 生成静态工厂代码与 manifest。
4
- * 即使存在 error 级诊断也会照常写出文件,由调用方根据 diagnostics 决定是否采用。
3
+ * Complete compilation pipeline: AST analysis -> validation -> generate static factory code and manifest.
4
+ * Files are emitted even when error-level diagnostics exist; caller decides adoption based on diagnostics.
5
5
  */
6
6
  export declare function compileProject(options: CompileOptions): Promise<CompileResult>;
7
7
  /**
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * ApplicationGraph:编译器从源码 AST 构建出的静态应用图。
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
- /** token 名(InjectionToken 变量名或类名)。 */
16
+ /** Token name (InjectionToken variable name or class name). */
17
17
  token: string;
18
18
  tokenKind: TokenKind;
19
19
  kind: ProviderKind;
@@ -22,12 +22,12 @@ export interface ProviderNode {
22
22
  useFactoryName?: string;
23
23
  useExisting?: string;
24
24
  scope: Scope;
25
- /** token 名,构造/工厂参数顺序。 */
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 符号的模块相对路径(供生成 import)。 */
30
+ /** Relative module path of useClass/useFactory/useValue symbol (for import generation). */
31
31
  importPath?: string;
32
32
  }
33
33
  export interface RouteNode {
@@ -49,7 +49,7 @@ export interface ControllerNode {
49
49
  routes: RouteNode[];
50
50
  file: string;
51
51
  importPath: string;
52
- /** 路由 schema 符号名 → 模块相对路径(供生成 import)。 */
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,46 +65,46 @@ export interface QueryNode {
65
65
  name: string;
66
66
  }
67
67
  export interface ModuleNode {
68
- /** @Module({ name }) 或 defineModule 的 name。 */
68
+ /** Name from @Module({ name }) or defineModule. */
69
69
  name: string;
70
70
  className: string;
71
- /** 模块标签(如 ['scope:case', 'type:feature']),用于架构边界治理。 */
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
- /** 被 import 模块的 name。 */
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
- /** 导出的 token 名。 */
81
+ /** Exported token names. */
82
82
  exports: string[];
83
83
  }
84
84
  export interface ApplicationGraph {
85
85
  modules: ModuleNode[];
86
- /** 被依赖但无任何模块提供的 token 名(平台注入)。 */
86
+ /** Depended token names provided by platform injection rather than any module. */
87
87
  externalTokens: string[];
88
88
  /**
89
- * 分析阶段产生的诊断(如 missing-deps),由 compileProject 合并进结果。
90
- * 不写入 app.manifest.json。
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 变量名 → 字符串 name(如 REQUEST_CONTEXT →
95
- * "supacloud.request-context"),供代码生成识别内置上下文 token。
96
- * 不写入 app.manifest.json。
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
- /** 项目根(含 tsconfig)。 */
101
+ /** Project root directory (containing tsconfig). */
102
102
  rootDir: string;
103
- /** glob,默认 ['**\/*.module.ts', '**\/*.ts']。 */
103
+ /** Glob patterns, defaults to ['**\/*.module.ts', '**\/*.ts']. */
104
104
  include?: string[];
105
- /** 生成目录(如 <rootDir>/generated)。 */
105
+ /** Output directory (e.g. <rootDir>/generated). */
106
106
  outDir: string;
107
- /** warn 级诊断升级为 error。 */
107
+ /** Upgrade warn-level diagnostics to error. */
108
108
  strict?: boolean;
109
109
  /** Built-in architecture boundary preset (for example, 'modular-monolith'). */
110
110
  moduleBoundaryPreset?: ModuleBoundaryPresetName;
package/dist/util.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * token 名 → services 对象的 key。
3
- * CASE_REPOSITORY → caseRepository、LOGGER → logger(常量命名转 camelCase),
4
- * CaseService → caseService(PascalCase 首字母小写)。
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
- /** 计算 from 目录到 to 文件的相对 import 路径(去扩展名,保证 ./ 或 ../ 前缀)。 */
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
- /** 内置上下文 token 的字符串 name(与 @supacloud/app 的 REQUEST_CONTEXT/JOB_CONTEXT 对齐)。 */
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
- /** 判断 token 是否为内置 request 上下文(变量名 REQUEST_CONTEXT 或 token name 匹配)。 */
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
- /** 判断 token 是否为内置 job 上下文。 */
14
+ /** Determines whether token is built-in job context. */
15
15
  export declare function isJobContextToken(token: string, tokenNames?: Record<string, string>): boolean;
@@ -1,6 +1,6 @@
1
1
  import type { ApplicationGraph, Diagnostic, ValidateOptions } from "./types";
2
2
  /**
3
- * 校验 ApplicationGraph,产出诊断列表。
4
- * strict 时 warn 级诊断升级为 error。
3
+ * Validates ApplicationGraph and produces diagnostics list.
4
+ * In strict mode, warn-level diagnostics are promoted to error.
5
5
  */
6
6
  export declare function validateGraph(graph: ApplicationGraph, options?: boolean | ValidateOptions): Diagnostic[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/compiler",
3
- "version": "0.4.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",