@hexaijs/plugin-contracts-generator 0.2.0 → 0.2.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/README.md +33 -25
- package/dist/ast-utils.d.ts +6 -0
- package/dist/ast-utils.d.ts.map +1 -0
- package/dist/ast-utils.js +73 -0
- package/dist/ast-utils.js.map +1 -0
- package/dist/class-analyzer.d.ts +16 -0
- package/dist/class-analyzer.d.ts.map +1 -0
- package/dist/class-analyzer.js +114 -0
- package/dist/class-analyzer.js.map +1 -0
- package/dist/cli.d.ts +32 -1
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +226 -2480
- package/dist/cli.js.map +1 -1
- package/dist/config-loader.d.ts +24 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +126 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/context-config.d.ts +44 -0
- package/dist/context-config.d.ts.map +1 -0
- package/dist/context-config.js +140 -0
- package/dist/context-config.js.map +1 -0
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +2 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/types.d.ts +182 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +49 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +112 -0
- package/dist/errors.js.map +1 -0
- package/dist/file-copier.d.ts +84 -0
- package/dist/file-copier.d.ts.map +1 -0
- package/dist/file-copier.js +721 -0
- package/dist/file-copier.js.map +1 -0
- package/dist/file-graph-resolver.d.ts +42 -0
- package/dist/file-graph-resolver.d.ts.map +1 -0
- package/dist/file-graph-resolver.js +138 -0
- package/dist/file-graph-resolver.js.map +1 -0
- package/dist/file-system.d.ts +26 -0
- package/dist/file-system.d.ts.map +1 -0
- package/dist/file-system.js +30 -0
- package/dist/file-system.js.map +1 -0
- package/dist/hexai-plugin.d.ts +16 -0
- package/dist/hexai-plugin.d.ts.map +1 -0
- package/dist/hexai-plugin.js +56 -0
- package/dist/hexai-plugin.js.map +1 -0
- package/dist/import-analyzer.d.ts +6 -0
- package/dist/import-analyzer.d.ts.map +1 -0
- package/dist/import-analyzer.js +39 -0
- package/dist/import-analyzer.js.map +1 -0
- package/dist/index.d.ts +39 -531
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -2739
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +21 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +43 -0
- package/dist/logger.js.map +1 -0
- package/dist/parser.d.ts +32 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +202 -0
- package/dist/parser.js.map +1 -0
- package/dist/pipeline.d.ts +57 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +148 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/reexport-generator.d.ts +81 -0
- package/dist/reexport-generator.d.ts.map +1 -0
- package/dist/reexport-generator.js +171 -0
- package/dist/reexport-generator.js.map +1 -0
- package/dist/registry-generator.d.ts +27 -0
- package/dist/registry-generator.d.ts.map +1 -0
- package/dist/registry-generator.js +104 -0
- package/dist/registry-generator.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -23
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +1 -38
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/message-registry.d.ts +23 -0
- package/dist/runtime/message-registry.d.ts.map +1 -0
- package/dist/runtime/message-registry.js +35 -0
- package/dist/runtime/message-registry.js.map +1 -0
- package/dist/scanner.d.ts +21 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +49 -0
- package/dist/scanner.js.map +1 -0
- package/dist/test-utils.d.ts +23 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +188 -0
- package/dist/test-utils.js.map +1 -0
- package/package.json +69 -64
- package/dist/cli-CPg-O4OY.d.ts +0 -214
- package/dist/decorators/index.d.ts +0 -144
- package/dist/decorators/index.js +0 -28
- package/dist/decorators/index.js.map +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export function createSourceFile(path = "test.ts", absolutePath) {
|
|
2
|
+
return {
|
|
3
|
+
absolutePath: absolutePath ?? `/project/src/${path}`,
|
|
4
|
+
relativePath: path,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function isSourceFile(obj) {
|
|
8
|
+
return (typeof obj === "object" &&
|
|
9
|
+
obj !== null &&
|
|
10
|
+
"absolutePath" in obj &&
|
|
11
|
+
"relativePath" in obj);
|
|
12
|
+
}
|
|
13
|
+
function isTypeRefBody(obj) {
|
|
14
|
+
return typeof obj === "object" && obj !== null && "kind" in obj;
|
|
15
|
+
}
|
|
16
|
+
export function createTypeDefinition(name, sourceFileOrBody, bodyArg) {
|
|
17
|
+
let sourceFile;
|
|
18
|
+
let body;
|
|
19
|
+
if (sourceFileOrBody === undefined) {
|
|
20
|
+
// createTypeDefinition(name)
|
|
21
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
22
|
+
body = { kind: "primitive", name: "string" };
|
|
23
|
+
}
|
|
24
|
+
else if (isSourceFile(sourceFileOrBody)) {
|
|
25
|
+
// createTypeDefinition(name, sourceFile) or createTypeDefinition(name, sourceFile, body)
|
|
26
|
+
sourceFile = sourceFileOrBody;
|
|
27
|
+
body =
|
|
28
|
+
bodyArg ?? { kind: "primitive", name: "string" };
|
|
29
|
+
}
|
|
30
|
+
else if (isTypeRefBody(sourceFileOrBody)) {
|
|
31
|
+
// createTypeDefinition(name, body)
|
|
32
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
33
|
+
body = sourceFileOrBody;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Fallback to defaults
|
|
37
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
38
|
+
body = { kind: "primitive", name: "string" };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
kind: "type",
|
|
43
|
+
sourceFile,
|
|
44
|
+
body,
|
|
45
|
+
exported: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createEventWithReferenceField(eventName, fieldName, referencedTypeName) {
|
|
49
|
+
return {
|
|
50
|
+
messageType: "event",
|
|
51
|
+
name: eventName,
|
|
52
|
+
sourceFile: createSourceFile("events.ts"),
|
|
53
|
+
fields: [
|
|
54
|
+
{
|
|
55
|
+
name: fieldName,
|
|
56
|
+
type: {
|
|
57
|
+
kind: "reference",
|
|
58
|
+
name: referencedTypeName,
|
|
59
|
+
},
|
|
60
|
+
optional: false,
|
|
61
|
+
readonly: true,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
sourceText: `export class ${eventName} extends Message<{ ${fieldName}: ${referencedTypeName} }> {}`,
|
|
65
|
+
imports: [],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function createCommandWithReferenceField(commandName, fieldName, referencedTypeName) {
|
|
69
|
+
return {
|
|
70
|
+
messageType: "command",
|
|
71
|
+
name: commandName,
|
|
72
|
+
sourceFile: createSourceFile("commands.ts"),
|
|
73
|
+
fields: [
|
|
74
|
+
{
|
|
75
|
+
name: fieldName,
|
|
76
|
+
type: {
|
|
77
|
+
kind: "reference",
|
|
78
|
+
name: referencedTypeName,
|
|
79
|
+
},
|
|
80
|
+
optional: false,
|
|
81
|
+
readonly: true,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
sourceText: `export class ${commandName} extends Message<{ ${fieldName}: ${referencedTypeName} }> {}`,
|
|
85
|
+
imports: [],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function createEventWithPrimitiveField(eventName, fieldName, primitiveName) {
|
|
89
|
+
return {
|
|
90
|
+
messageType: "event",
|
|
91
|
+
name: eventName,
|
|
92
|
+
sourceFile: createSourceFile("events.ts"),
|
|
93
|
+
fields: [
|
|
94
|
+
{
|
|
95
|
+
name: fieldName,
|
|
96
|
+
type: {
|
|
97
|
+
kind: "primitive",
|
|
98
|
+
name: primitiveName,
|
|
99
|
+
},
|
|
100
|
+
optional: false,
|
|
101
|
+
readonly: true,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
sourceText: `export class ${eventName} extends Message<{ ${fieldName}: ${primitiveName} }> {}`,
|
|
105
|
+
imports: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function createField(name, type, optional = false, readonly = false) {
|
|
109
|
+
return {
|
|
110
|
+
name,
|
|
111
|
+
type,
|
|
112
|
+
optional,
|
|
113
|
+
readonly,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function createClassDefinition(name, options = {}) {
|
|
117
|
+
const sourceFile = options.sourceFile ?? createSourceFile(`${name}.ts`);
|
|
118
|
+
const sourceText = options.sourceText ?? `export class ${name} { constructor() {} }`;
|
|
119
|
+
return {
|
|
120
|
+
name,
|
|
121
|
+
kind: "class",
|
|
122
|
+
sourceFile,
|
|
123
|
+
sourceText,
|
|
124
|
+
imports: options.imports ?? [],
|
|
125
|
+
dependencies: options.dependencies ?? [],
|
|
126
|
+
baseClass: options.baseClass,
|
|
127
|
+
exported: options.exported ?? true,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function createInMemoryFileSystem() {
|
|
131
|
+
const files = new Map();
|
|
132
|
+
const directories = new Set();
|
|
133
|
+
return {
|
|
134
|
+
files,
|
|
135
|
+
directories,
|
|
136
|
+
async readFile(filePath) {
|
|
137
|
+
const content = files.get(filePath);
|
|
138
|
+
if (content === undefined) {
|
|
139
|
+
throw new Error(`File not found: ${filePath}`);
|
|
140
|
+
}
|
|
141
|
+
return content;
|
|
142
|
+
},
|
|
143
|
+
async readdir(dirPath) {
|
|
144
|
+
const entries = [];
|
|
145
|
+
const normalizedDir = dirPath.endsWith("/") ? dirPath : dirPath + "/";
|
|
146
|
+
for (const filePath of files.keys()) {
|
|
147
|
+
if (filePath.startsWith(normalizedDir)) {
|
|
148
|
+
const relativePath = filePath.slice(normalizedDir.length);
|
|
149
|
+
const firstPart = relativePath.split("/")[0];
|
|
150
|
+
if (firstPart && !entries.includes(firstPart)) {
|
|
151
|
+
entries.push(firstPart);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
for (const dir of directories) {
|
|
156
|
+
if (dir.startsWith(normalizedDir)) {
|
|
157
|
+
const relativePath = dir.slice(normalizedDir.length);
|
|
158
|
+
const firstPart = relativePath.split("/")[0];
|
|
159
|
+
if (firstPart && !entries.includes(firstPart)) {
|
|
160
|
+
entries.push(firstPart);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return entries;
|
|
165
|
+
},
|
|
166
|
+
async writeFile(filePath, content) {
|
|
167
|
+
files.set(filePath, content);
|
|
168
|
+
},
|
|
169
|
+
async mkdir(dirPath, _options) {
|
|
170
|
+
directories.add(dirPath);
|
|
171
|
+
},
|
|
172
|
+
async exists(filePath) {
|
|
173
|
+
return files.has(filePath) || directories.has(filePath);
|
|
174
|
+
},
|
|
175
|
+
async stat(filePath) {
|
|
176
|
+
const isDir = directories.has(filePath);
|
|
177
|
+
const isFile = files.has(filePath);
|
|
178
|
+
if (!isDir && !isFile) {
|
|
179
|
+
throw new Error(`Path not found: ${filePath}`);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
isDirectory: () => isDir,
|
|
183
|
+
isFile: () => isFile,
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,gBAAgB,CAC5B,IAAI,GAAW,SAAS,EACxB,YAAqB;IAErB,OAAO;QACH,YAAY,EAAE,YAAY,IAAI,gBAAgB,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OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC5B,CAAC;gBACL,CAAC;YACL,CAAC;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAe;YAC7C,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,QAAkC;YAC3D,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,QAAgB;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5D,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,QAAgB;YACvB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAEnC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;YACnD,CAAC;YAED,OAAO;gBACH,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;gBACxB,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM;aACvB,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,67 +1,72 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"name": "@hexaijs/plugin-contracts-generator",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.2.2",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"description": "Collect domain events and commands from bounded contexts and generate frontend-compatible contracts package",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Sangwoo Hyun <wkdny.hyun@gmail.com>",
|
|
11
|
+
"contributors": [
|
|
12
|
+
"Seungcheol Baek <victoryiron.baek@gmail.com>",
|
|
13
|
+
"Donghyun Lee <edonghyun@naver.com>"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/workingdanny911/hexai.git",
|
|
18
|
+
"directory": "packages/plugin-contracts-generator"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/workingdanny911/hexai#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/workingdanny911/hexai/issues"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"hexai",
|
|
26
|
+
"hexagonal",
|
|
27
|
+
"clean-architecture",
|
|
28
|
+
"ddd",
|
|
29
|
+
"contracts",
|
|
30
|
+
"code-generation",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js"
|
|
5
41
|
},
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"author": "Sangwoo Hyun <wkdny.hyun@gmail.com>",
|
|
11
|
-
"contributors": [
|
|
12
|
-
"Seungcheol Baek <victoryiron.baek@gmail.com>",
|
|
13
|
-
"Donghyun Lee <edonghyun@naver.com>"
|
|
14
|
-
],
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/workingdanny911/hexai.git",
|
|
18
|
-
"directory": "packages/plugin-contracts-generator"
|
|
42
|
+
"./runtime": {
|
|
43
|
+
"types": "./dist/runtime/index.d.ts",
|
|
44
|
+
"import": "./dist/runtime/index.js"
|
|
19
45
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"scripts": {
|
|
48
|
-
"test": "vitest run",
|
|
49
|
-
"build": "tsup"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"glob": "^10.3.0",
|
|
53
|
-
"minimatch": "^9.0.0",
|
|
54
|
-
"reflect-metadata": "^0.2.2"
|
|
55
|
-
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"@hexaijs/cli": "^0.2.0",
|
|
58
|
-
"typescript": "^5.0.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@hexaijs/cli": "workspace:^",
|
|
62
|
-
"@hexaijs/core": "workspace:^",
|
|
63
|
-
"@hexaijs/tooling": "workspace:*",
|
|
64
|
-
"@types/node": "^20.11.0",
|
|
65
|
-
"typescript": "^5.3.0"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"bin": {
|
|
49
|
+
"generate-contracts": "dist/cli.js"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"glob": "^10.3.0",
|
|
53
|
+
"minimatch": "^9.0.0",
|
|
54
|
+
"@hexaijs/contracts": "^0.1.2"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@hexaijs/cli": "^0.2.0",
|
|
58
|
+
"typescript": "^5.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@typescript/native-preview": "^7.0.0-dev",
|
|
62
|
+
"@types/node": "^20.11.0",
|
|
63
|
+
"typescript": "^5.3.0",
|
|
64
|
+
"@hexaijs/tooling": "0.1.0",
|
|
65
|
+
"@hexaijs/cli": "^0.2.2",
|
|
66
|
+
"@hexaijs/core": "^0.9.1"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"build": "tsgo -p tsconfig.build.json"
|
|
71
|
+
}
|
|
72
|
+
}
|
package/dist/cli-CPg-O4OY.d.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
interface SourceFile {
|
|
2
|
-
readonly absolutePath: string;
|
|
3
|
-
readonly relativePath: string;
|
|
4
|
-
readonly packageName?: string;
|
|
5
|
-
}
|
|
6
|
-
type TypeRef = PrimitiveType | ArrayType | ObjectType | UnionType | IntersectionType | ReferenceType | LiteralType | TupleType | FunctionType;
|
|
7
|
-
interface PrimitiveType {
|
|
8
|
-
readonly kind: 'primitive';
|
|
9
|
-
readonly name: 'string' | 'number' | 'boolean' | 'null' | 'undefined' | 'void' | 'any' | 'unknown' | 'never' | 'bigint' | 'symbol';
|
|
10
|
-
}
|
|
11
|
-
interface ArrayType {
|
|
12
|
-
readonly kind: 'array';
|
|
13
|
-
readonly elementType: TypeRef;
|
|
14
|
-
}
|
|
15
|
-
interface ObjectType {
|
|
16
|
-
readonly kind: 'object';
|
|
17
|
-
readonly fields: readonly Field[];
|
|
18
|
-
}
|
|
19
|
-
interface UnionType {
|
|
20
|
-
readonly kind: 'union';
|
|
21
|
-
readonly types: readonly TypeRef[];
|
|
22
|
-
}
|
|
23
|
-
interface IntersectionType {
|
|
24
|
-
readonly kind: 'intersection';
|
|
25
|
-
readonly types: readonly TypeRef[];
|
|
26
|
-
}
|
|
27
|
-
interface ReferenceType {
|
|
28
|
-
readonly kind: 'reference';
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly typeArguments?: readonly TypeRef[];
|
|
31
|
-
}
|
|
32
|
-
interface LiteralType {
|
|
33
|
-
readonly kind: 'literal';
|
|
34
|
-
readonly value: string | number | boolean;
|
|
35
|
-
}
|
|
36
|
-
interface TupleType {
|
|
37
|
-
readonly kind: 'tuple';
|
|
38
|
-
readonly elements: readonly TypeRef[];
|
|
39
|
-
}
|
|
40
|
-
interface FunctionType {
|
|
41
|
-
readonly kind: 'function';
|
|
42
|
-
readonly parameters: readonly FunctionParameter[];
|
|
43
|
-
readonly returnType: TypeRef;
|
|
44
|
-
}
|
|
45
|
-
interface FunctionParameter {
|
|
46
|
-
readonly name: string;
|
|
47
|
-
readonly type: TypeRef;
|
|
48
|
-
readonly optional: boolean;
|
|
49
|
-
}
|
|
50
|
-
interface Field {
|
|
51
|
-
readonly name: string;
|
|
52
|
-
readonly type: TypeRef;
|
|
53
|
-
readonly optional: boolean;
|
|
54
|
-
readonly readonly: boolean;
|
|
55
|
-
}
|
|
56
|
-
type TypeDefinitionKind = 'interface' | 'type' | 'enum' | 'class';
|
|
57
|
-
interface TypeDefinition {
|
|
58
|
-
readonly name: string;
|
|
59
|
-
readonly kind: TypeDefinitionKind;
|
|
60
|
-
readonly sourceFile: SourceFile;
|
|
61
|
-
readonly body: TypeRef;
|
|
62
|
-
readonly typeParameters?: readonly string[];
|
|
63
|
-
readonly exported: boolean;
|
|
64
|
-
}
|
|
65
|
-
interface EnumMember {
|
|
66
|
-
readonly name: string;
|
|
67
|
-
readonly value?: string | number;
|
|
68
|
-
}
|
|
69
|
-
interface EnumDefinition extends Omit<TypeDefinition, 'kind' | 'body'> {
|
|
70
|
-
readonly kind: 'enum';
|
|
71
|
-
readonly members: readonly EnumMember[];
|
|
72
|
-
}
|
|
73
|
-
interface ClassImport {
|
|
74
|
-
readonly names: readonly string[];
|
|
75
|
-
readonly source: string;
|
|
76
|
-
readonly isTypeOnly: boolean;
|
|
77
|
-
readonly isExternal: boolean;
|
|
78
|
-
}
|
|
79
|
-
interface ClassDefinition {
|
|
80
|
-
readonly name: string;
|
|
81
|
-
readonly kind: 'class';
|
|
82
|
-
readonly sourceFile: SourceFile;
|
|
83
|
-
readonly sourceText: string;
|
|
84
|
-
readonly imports: readonly ClassImport[];
|
|
85
|
-
readonly dependencies: readonly string[];
|
|
86
|
-
readonly baseClass?: string;
|
|
87
|
-
readonly exported: boolean;
|
|
88
|
-
}
|
|
89
|
-
interface MessageBase {
|
|
90
|
-
readonly name: string;
|
|
91
|
-
readonly sourceFile: SourceFile;
|
|
92
|
-
readonly fields: readonly Field[];
|
|
93
|
-
readonly baseClass?: string;
|
|
94
|
-
readonly sourceText: string;
|
|
95
|
-
readonly imports: readonly ClassImport[];
|
|
96
|
-
}
|
|
97
|
-
interface DomainEvent extends MessageBase {
|
|
98
|
-
readonly messageType: 'event';
|
|
99
|
-
readonly version?: number;
|
|
100
|
-
readonly context?: string;
|
|
101
|
-
readonly payloadType?: TypeRef;
|
|
102
|
-
}
|
|
103
|
-
interface Command extends MessageBase {
|
|
104
|
-
readonly messageType: 'command';
|
|
105
|
-
readonly resultType?: TypeRef;
|
|
106
|
-
readonly context?: string;
|
|
107
|
-
readonly payloadType?: TypeRef;
|
|
108
|
-
}
|
|
109
|
-
interface Query extends MessageBase {
|
|
110
|
-
readonly messageType: 'query';
|
|
111
|
-
readonly resultType?: TypeRef;
|
|
112
|
-
readonly context?: string;
|
|
113
|
-
readonly payloadType?: TypeRef;
|
|
114
|
-
}
|
|
115
|
-
type Message = DomainEvent | Command | Query;
|
|
116
|
-
/** Used to filter which decorators the scanner should look for. */
|
|
117
|
-
type MessageType = Message['messageType'];
|
|
118
|
-
type ImportSource = {
|
|
119
|
-
readonly type: 'local';
|
|
120
|
-
readonly path: string;
|
|
121
|
-
} | {
|
|
122
|
-
readonly type: 'external';
|
|
123
|
-
readonly package: string;
|
|
124
|
-
};
|
|
125
|
-
type DependencyKind = 'type' | 'value' | 'class';
|
|
126
|
-
interface Dependency {
|
|
127
|
-
readonly name: string;
|
|
128
|
-
readonly source: ImportSource;
|
|
129
|
-
readonly kind: DependencyKind;
|
|
130
|
-
readonly definition?: TypeDefinition;
|
|
131
|
-
}
|
|
132
|
-
interface SourceLocation {
|
|
133
|
-
readonly file: string;
|
|
134
|
-
readonly message: string;
|
|
135
|
-
readonly line?: number;
|
|
136
|
-
readonly column?: number;
|
|
137
|
-
}
|
|
138
|
-
type ExtractionError = SourceLocation;
|
|
139
|
-
type ExtractionWarning = SourceLocation;
|
|
140
|
-
interface ExtractionResult {
|
|
141
|
-
readonly events: readonly DomainEvent[];
|
|
142
|
-
readonly commands: readonly Command[];
|
|
143
|
-
readonly types: readonly TypeDefinition[];
|
|
144
|
-
readonly dependencies: readonly Dependency[];
|
|
145
|
-
readonly errors: readonly ExtractionError[];
|
|
146
|
-
readonly warnings: readonly ExtractionWarning[];
|
|
147
|
-
}
|
|
148
|
-
/** Customizes decorator names used to identify public messages. Unspecified names use defaults. */
|
|
149
|
-
interface DecoratorNames {
|
|
150
|
-
event?: string;
|
|
151
|
-
command?: string;
|
|
152
|
-
query?: string;
|
|
153
|
-
}
|
|
154
|
-
interface ResponseNamingConvention {
|
|
155
|
-
readonly messageSuffix: string;
|
|
156
|
-
readonly responseSuffix: string;
|
|
157
|
-
}
|
|
158
|
-
interface Config {
|
|
159
|
-
readonly sourceDir: string;
|
|
160
|
-
readonly outputDir: string;
|
|
161
|
-
readonly include?: readonly string[];
|
|
162
|
-
readonly exclude?: readonly string[];
|
|
163
|
-
readonly externalPackages?: Readonly<Record<string, string>>;
|
|
164
|
-
readonly decoratorNames?: DecoratorNames;
|
|
165
|
-
readonly responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
166
|
-
}
|
|
167
|
-
declare function isPrimitiveType(type: TypeRef): type is PrimitiveType;
|
|
168
|
-
declare function isArrayType(type: TypeRef): type is ArrayType;
|
|
169
|
-
declare function isObjectType(type: TypeRef): type is ObjectType;
|
|
170
|
-
declare function isUnionType(type: TypeRef): type is UnionType;
|
|
171
|
-
declare function isIntersectionType(type: TypeRef): type is IntersectionType;
|
|
172
|
-
declare function isReferenceType(type: TypeRef): type is ReferenceType;
|
|
173
|
-
declare function isLiteralType(type: TypeRef): type is LiteralType;
|
|
174
|
-
declare function isTupleType(type: TypeRef): type is TupleType;
|
|
175
|
-
declare function isFunctionType(type: TypeRef): type is FunctionType;
|
|
176
|
-
declare function isDomainEvent(message: Message): message is DomainEvent;
|
|
177
|
-
declare function isCommand(message: Message): message is Command;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Options for runWithConfig when config is provided directly.
|
|
181
|
-
*/
|
|
182
|
-
interface RunWithConfigOptions {
|
|
183
|
-
outputDir: string;
|
|
184
|
-
messageTypes?: MessageType[];
|
|
185
|
-
generateMessageRegistry?: boolean;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Plugin configuration structure for contracts generator.
|
|
189
|
-
* This is the config passed from hexai.config.ts.
|
|
190
|
-
*/
|
|
191
|
-
interface ContractsPluginConfig {
|
|
192
|
-
contexts: Array<{
|
|
193
|
-
name: string;
|
|
194
|
-
path: string;
|
|
195
|
-
sourceDir?: string;
|
|
196
|
-
tsconfigPath?: string;
|
|
197
|
-
}>;
|
|
198
|
-
pathAliasRewrites?: Record<string, string>;
|
|
199
|
-
externalDependencies?: Record<string, string>;
|
|
200
|
-
decoratorNames?: DecoratorNames;
|
|
201
|
-
responseNamingConventions?: ResponseNamingConvention[];
|
|
202
|
-
removeDecorators?: boolean;
|
|
203
|
-
}
|
|
204
|
-
declare function run(args: string[]): Promise<void>;
|
|
205
|
-
/**
|
|
206
|
-
* Run contracts generator with config provided directly.
|
|
207
|
-
* This is used by the hexai CLI integration where config comes from hexai.config.ts.
|
|
208
|
-
*
|
|
209
|
-
* @param options - CLI options (outputDir, messageTypes, generateMessageRegistry)
|
|
210
|
-
* @param pluginConfig - Plugin configuration from hexai.config.ts
|
|
211
|
-
*/
|
|
212
|
-
declare function runWithConfig(options: RunWithConfigOptions, pluginConfig: ContractsPluginConfig): Promise<void>;
|
|
213
|
-
|
|
214
|
-
export { type ArrayType as A, isObjectType as B, type Command as C, type DecoratorNames as D, type EnumDefinition as E, type Field as F, isPrimitiveType as G, isReferenceType as H, type ImportSource as I, isTupleType as J, isUnionType as K, type LiteralType as L, type MessageType as M, type RunWithConfigOptions as N, type ObjectType as O, type PrimitiveType as P, type Query as Q, type ResponseNamingConvention as R, type SourceFile as S, type TypeDefinition as T, type UnionType as U, run as V, runWithConfig as W, type DomainEvent as a, type ContractsPluginConfig as b, type ClassDefinition as c, type ClassImport as d, type Config as e, type Dependency as f, type DependencyKind as g, type EnumMember as h, type ExtractionError as i, type ExtractionResult as j, type ExtractionWarning as k, type FunctionParameter as l, type FunctionType as m, type IntersectionType as n, type Message as o, type MessageBase as p, type ReferenceType as q, type TupleType as r, type TypeDefinitionKind as s, type TypeRef as t, isArrayType as u, isCommand as v, isDomainEvent as w, isFunctionType as x, isIntersectionType as y, isLiteralType as z };
|