@hexaijs/plugin-contracts-generator 0.1.1 → 0.2.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/README.md +38 -27
- package/dist/cli-DajurpEQ.d.ts +277 -0
- package/dist/cli.d.ts +1 -35
- package/dist/cli.js +2474 -233
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +461 -40
- package/dist/index.js +2711 -91
- package/dist/index.js.map +1 -1
- package/dist/runtime/index.d.ts +23 -2
- package/dist/runtime/index.js +38 -5
- package/dist/runtime/index.js.map +1 -1
- package/package.json +11 -19
- package/dist/ast-utils.d.ts +0 -6
- package/dist/ast-utils.d.ts.map +0 -1
- package/dist/ast-utils.js +0 -111
- package/dist/ast-utils.js.map +0 -1
- package/dist/class-analyzer.d.ts +0 -16
- package/dist/class-analyzer.d.ts.map +0 -1
- package/dist/class-analyzer.js +0 -155
- package/dist/class-analyzer.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/config-loader.d.ts +0 -34
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -188
- package/dist/config-loader.js.map +0 -1
- package/dist/decorators/index.d.ts +0 -143
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js +0 -123
- package/dist/decorators/index.js.map +0 -1
- package/dist/domain/index.d.ts +0 -2
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -18
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/types.d.ts +0 -182
- package/dist/domain/types.d.ts.map +0 -1
- package/dist/domain/types.js +0 -65
- package/dist/domain/types.js.map +0 -1
- package/dist/errors.d.ts +0 -79
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -138
- package/dist/errors.js.map +0 -1
- package/dist/file-copier.d.ts +0 -84
- package/dist/file-copier.d.ts.map +0 -1
- package/dist/file-copier.js +0 -758
- package/dist/file-copier.js.map +0 -1
- package/dist/file-graph-resolver.d.ts +0 -47
- package/dist/file-graph-resolver.d.ts.map +0 -1
- package/dist/file-graph-resolver.js +0 -230
- package/dist/file-graph-resolver.js.map +0 -1
- package/dist/file-system.d.ts +0 -26
- package/dist/file-system.d.ts.map +0 -1
- package/dist/file-system.js +0 -34
- package/dist/file-system.js.map +0 -1
- package/dist/hexai-plugin.d.ts +0 -16
- package/dist/hexai-plugin.d.ts.map +0 -1
- package/dist/hexai-plugin.js +0 -59
- package/dist/hexai-plugin.js.map +0 -1
- package/dist/import-analyzer.d.ts +0 -6
- package/dist/import-analyzer.d.ts.map +0 -1
- package/dist/import-analyzer.js +0 -77
- package/dist/import-analyzer.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logger.d.ts +0 -21
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -47
- package/dist/logger.js.map +0 -1
- package/dist/parser.d.ts +0 -32
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -209
- package/dist/parser.js.map +0 -1
- package/dist/pipeline.d.ts +0 -56
- package/dist/pipeline.d.ts.map +0 -1
- package/dist/pipeline.js +0 -152
- package/dist/pipeline.js.map +0 -1
- package/dist/reexport-generator.d.ts +0 -81
- package/dist/reexport-generator.d.ts.map +0 -1
- package/dist/reexport-generator.js +0 -208
- package/dist/reexport-generator.js.map +0 -1
- package/dist/registry-generator.d.ts +0 -27
- package/dist/registry-generator.d.ts.map +0 -1
- package/dist/registry-generator.js +0 -108
- package/dist/registry-generator.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/message-registry.d.ts +0 -23
- package/dist/runtime/message-registry.d.ts.map +0 -1
- package/dist/runtime/message-registry.js +0 -39
- package/dist/runtime/message-registry.js.map +0 -1
- package/dist/scanner.d.ts +0 -21
- package/dist/scanner.d.ts.map +0 -1
- package/dist/scanner.js +0 -53
- package/dist/scanner.js.map +0 -1
- package/dist/test-utils.d.ts +0 -23
- package/dist/test-utils.d.ts.map +0 -1
- package/dist/test-utils.js +0 -198
- package/dist/test-utils.js.map +0 -1
- package/dist/tsconfig-loader.d.ts +0 -8
- package/dist/tsconfig-loader.d.ts.map +0 -1
- package/dist/tsconfig-loader.js +0 -64
- package/dist/tsconfig-loader.js.map +0 -1
package/README.md
CHANGED
|
@@ -30,14 +30,14 @@ npm install @hexaijs/plugin-contracts-generator
|
|
|
30
30
|
The package provides three decorators that mark messages for extraction. These decorators have **no runtime overhead** - they simply tag classes for discovery during the build process.
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
-
import { PublicEvent, PublicCommand, PublicQuery } from "@hexaijs/
|
|
33
|
+
import { PublicEvent, PublicCommand, PublicQuery } from "@hexaijs/contracts/decorators";
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
**@PublicEvent()** - Marks a domain event as part of the public contract:
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
import { DomainEvent } from "@hexaijs/core";
|
|
40
|
-
import { PublicEvent } from "@hexaijs/
|
|
40
|
+
import { PublicEvent } from "@hexaijs/contracts/decorators";
|
|
41
41
|
|
|
42
42
|
@PublicEvent()
|
|
43
43
|
export class OrderPlaced extends DomainEvent<{
|
|
@@ -52,7 +52,7 @@ export class OrderPlaced extends DomainEvent<{
|
|
|
52
52
|
**@PublicCommand()** - Marks a command as part of the public contract:
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import { PublicCommand } from "@hexaijs/
|
|
55
|
+
import { PublicCommand } from "@hexaijs/contracts/decorators";
|
|
56
56
|
|
|
57
57
|
@PublicCommand()
|
|
58
58
|
export class CreateOrderRequest extends BaseRequest<{
|
|
@@ -70,7 +70,7 @@ export type CreateOrderResponse = {
|
|
|
70
70
|
**@PublicQuery()** - Marks a query as part of the public contract:
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
|
-
import { PublicQuery } from "@hexaijs/
|
|
73
|
+
import { PublicQuery } from "@hexaijs/contracts/decorators";
|
|
74
74
|
|
|
75
75
|
@PublicQuery({ response: "OrderDetails" })
|
|
76
76
|
export class GetOrderQuery extends BaseRequest<{
|
|
@@ -101,21 +101,16 @@ export default {
|
|
|
101
101
|
contexts: [
|
|
102
102
|
{
|
|
103
103
|
name: "order",
|
|
104
|
-
|
|
105
|
-
tsconfigPath: "
|
|
104
|
+
path: "packages/order",
|
|
105
|
+
tsconfigPath: "tsconfig.json", // optional, relative to path
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
name: "inventory",
|
|
109
|
-
|
|
109
|
+
path: "packages/inventory",
|
|
110
|
+
sourceDir: "lib", // optional, defaults to "src"
|
|
110
111
|
},
|
|
111
112
|
],
|
|
112
113
|
|
|
113
|
-
// Output package configuration (required)
|
|
114
|
-
outputPackage: {
|
|
115
|
-
name: "@myorg/contracts",
|
|
116
|
-
dir: "packages/contracts",
|
|
117
|
-
},
|
|
118
|
-
|
|
119
114
|
// Path alias rewrite rules (optional)
|
|
120
115
|
pathAliasRewrites: {
|
|
121
116
|
"@myorg/": "@/",
|
|
@@ -132,25 +127,38 @@ export default {
|
|
|
132
127
|
{ messageSuffix: "Query", responseSuffix: "QueryResult" },
|
|
133
128
|
{ messageSuffix: "Request", responseSuffix: "Response" },
|
|
134
129
|
],
|
|
130
|
+
|
|
131
|
+
// Custom decorator names (optional, defaults shown)
|
|
132
|
+
decoratorNames: {
|
|
133
|
+
event: "PublicEvent",
|
|
134
|
+
command: "PublicCommand",
|
|
135
|
+
query: "PublicQuery",
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
// Strip decorators from generated output (optional, default: true)
|
|
139
|
+
removeDecorators: true,
|
|
135
140
|
},
|
|
136
141
|
};
|
|
137
142
|
```
|
|
138
143
|
|
|
144
|
+
Each context requires `name` and `path`. The `path` is the base directory of the context (relative to the config file). Within that directory:
|
|
145
|
+
- `sourceDir` defaults to `"src"` (resolved relative to `path`)
|
|
146
|
+
- `tsconfigPath` defaults to `"tsconfig.json"` (resolved relative to `path`)
|
|
147
|
+
|
|
139
148
|
For monorepos with many packages, use glob patterns to auto-discover contexts:
|
|
140
149
|
|
|
141
150
|
```typescript
|
|
142
151
|
export default {
|
|
143
152
|
contracts: {
|
|
144
153
|
contexts: ["packages/*"], // Matches all directories under packages/
|
|
145
|
-
outputPackage: {
|
|
146
|
-
name: "@myorg/contracts",
|
|
147
|
-
dir: "packages/contracts",
|
|
148
|
-
},
|
|
149
154
|
},
|
|
150
155
|
};
|
|
151
156
|
```
|
|
152
157
|
|
|
153
|
-
Each matched
|
|
158
|
+
Each matched directory is treated as a context with sensible defaults:
|
|
159
|
+
- Context name = directory name (e.g., `packages/auth` → `auth`)
|
|
160
|
+
- Source directory = `src/` (default)
|
|
161
|
+
- TypeScript config = `tsconfig.json` (auto-detected if exists)
|
|
154
162
|
|
|
155
163
|
### Response Types
|
|
156
164
|
|
|
@@ -205,17 +213,19 @@ The generator handles two types of files differently:
|
|
|
205
213
|
Run the generator from your monorepo root:
|
|
206
214
|
|
|
207
215
|
```bash
|
|
208
|
-
#
|
|
209
|
-
npx contracts-generator
|
|
216
|
+
# Required: --output-dir (-o) specifies where contracts are generated
|
|
217
|
+
npx contracts-generator --output-dir packages/contracts/src
|
|
210
218
|
|
|
211
|
-
# Specify config file path
|
|
212
|
-
npx contracts-generator --config ./
|
|
219
|
+
# Specify config file path (default: application.config.ts)
|
|
220
|
+
npx contracts-generator -o packages/contracts/src --config ./app.config.ts
|
|
213
221
|
|
|
214
222
|
# Filter by message types
|
|
215
|
-
npx contracts-generator -m event # Extract only events
|
|
216
|
-
npx contracts-generator -m command # Extract only commands
|
|
217
|
-
npx contracts-generator -m
|
|
218
|
-
|
|
223
|
+
npx contracts-generator -o packages/contracts/src -m event # Extract only events
|
|
224
|
+
npx contracts-generator -o packages/contracts/src -m command # Extract only commands
|
|
225
|
+
npx contracts-generator -o packages/contracts/src -m event,command # Extract events and commands
|
|
226
|
+
|
|
227
|
+
# Generate with message registry (index.ts)
|
|
228
|
+
npx contracts-generator -o packages/contracts/src --generate-message-registry
|
|
219
229
|
```
|
|
220
230
|
|
|
221
231
|
### Programmatic API
|
|
@@ -252,6 +262,7 @@ contracts/
|
|
|
252
262
|
│ ├── {context}/
|
|
253
263
|
│ │ ├── events.ts
|
|
254
264
|
│ │ ├── commands.ts
|
|
265
|
+
│ │ ├── queries.ts
|
|
255
266
|
│ │ ├── types.ts # Dependent types + Response types
|
|
256
267
|
│ │ └── index.ts # Barrel exports
|
|
257
268
|
│ └── index.ts # Namespace exports + MessageRegistry
|
|
@@ -313,7 +324,7 @@ try {
|
|
|
313
324
|
**Error hierarchy:**
|
|
314
325
|
|
|
315
326
|
- `MessageParserError` (base)
|
|
316
|
-
- `ConfigurationError` → `ConfigLoadError
|
|
327
|
+
- `ConfigurationError` → `ConfigLoadError`
|
|
317
328
|
- `FileSystemError` → `FileNotFoundError`, `FileReadError`, `FileWriteError`
|
|
318
329
|
- `ParseError` → `JsonParseError`
|
|
319
330
|
- `ResolutionError` → `ModuleResolutionError`
|
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
interface FileStats {
|
|
180
|
+
isDirectory(): boolean;
|
|
181
|
+
isFile(): boolean;
|
|
182
|
+
}
|
|
183
|
+
interface FileSystem {
|
|
184
|
+
readFile(path: string): Promise<string>;
|
|
185
|
+
readdir(path: string): Promise<string[]>;
|
|
186
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
187
|
+
mkdir(path: string, options?: {
|
|
188
|
+
recursive?: boolean;
|
|
189
|
+
}): Promise<void>;
|
|
190
|
+
exists(path: string): Promise<boolean>;
|
|
191
|
+
stat(path: string): Promise<FileStats>;
|
|
192
|
+
}
|
|
193
|
+
declare class NodeFileSystem implements FileSystem {
|
|
194
|
+
readFile(path: string): Promise<string>;
|
|
195
|
+
readdir(path: string): Promise<string[]>;
|
|
196
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
197
|
+
mkdir(path: string, options?: {
|
|
198
|
+
recursive?: boolean;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
exists(path: string): Promise<boolean>;
|
|
201
|
+
stat(path: string): Promise<FileStats>;
|
|
202
|
+
}
|
|
203
|
+
declare const nodeFileSystem: NodeFileSystem;
|
|
204
|
+
|
|
205
|
+
interface InputContextConfig {
|
|
206
|
+
readonly name: string;
|
|
207
|
+
readonly path: string;
|
|
208
|
+
readonly sourceDir?: string;
|
|
209
|
+
readonly tsconfigPath?: string;
|
|
210
|
+
readonly responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Encapsulates context configuration with path resolution capabilities.
|
|
214
|
+
* Created via factory method to ensure proper initialization.
|
|
215
|
+
*/
|
|
216
|
+
declare class ContextConfig {
|
|
217
|
+
private readonly fs;
|
|
218
|
+
private readonly tsconfig;
|
|
219
|
+
readonly name: string;
|
|
220
|
+
readonly sourceDir: string;
|
|
221
|
+
readonly responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
222
|
+
private constructor();
|
|
223
|
+
/**
|
|
224
|
+
* Factory method to create ContextConfig with properly loaded tsconfig.
|
|
225
|
+
*/
|
|
226
|
+
static create(input: InputContextConfig, configDir: string, fs?: FileSystem): Promise<ContextConfig>;
|
|
227
|
+
private static loadTsconfig;
|
|
228
|
+
/**
|
|
229
|
+
* Creates a ContextConfig without async loading (for cases where tsconfig is not needed
|
|
230
|
+
* or already handled externally).
|
|
231
|
+
*/
|
|
232
|
+
static createSync(name: string, sourceDir: string, fs?: FileSystem, responseNamingConventions?: readonly ResponseNamingConvention[]): ContextConfig;
|
|
233
|
+
/**
|
|
234
|
+
* Resolves a module specifier (path alias) to actual file path.
|
|
235
|
+
* Only handles non-relative imports (path aliases).
|
|
236
|
+
*
|
|
237
|
+
* @param moduleSpecifier - The import path to resolve (e.g., "@/utils/helper")
|
|
238
|
+
* @returns Object with resolvedPath (null if external) and isExternal flag
|
|
239
|
+
*/
|
|
240
|
+
resolvePath(moduleSpecifier: string): Promise<{
|
|
241
|
+
resolvedPath: string | null;
|
|
242
|
+
isExternal: boolean;
|
|
243
|
+
}>;
|
|
244
|
+
private tryResolveWithExtensions;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Options for runWithConfig when config is provided directly.
|
|
249
|
+
*/
|
|
250
|
+
interface RunWithConfigOptions {
|
|
251
|
+
outputDir: string;
|
|
252
|
+
messageTypes?: MessageType[];
|
|
253
|
+
generateMessageRegistry?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Plugin configuration structure for contracts generator.
|
|
257
|
+
* This is the config passed from hexai.config.ts.
|
|
258
|
+
*/
|
|
259
|
+
interface ContractsPluginConfig {
|
|
260
|
+
contexts: Array<string | InputContextConfig>;
|
|
261
|
+
pathAliasRewrites?: Record<string, string>;
|
|
262
|
+
externalDependencies?: Record<string, string>;
|
|
263
|
+
decoratorNames?: DecoratorNames;
|
|
264
|
+
responseNamingConventions?: ResponseNamingConvention[];
|
|
265
|
+
removeDecorators?: boolean;
|
|
266
|
+
}
|
|
267
|
+
declare function run(args: string[]): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Run contracts generator with config provided directly.
|
|
270
|
+
* This is used by the hexai CLI integration where config comes from hexai.config.ts.
|
|
271
|
+
*
|
|
272
|
+
* @param options - CLI options (outputDir, messageTypes, generateMessageRegistry)
|
|
273
|
+
* @param pluginConfig - Plugin configuration from hexai.config.ts
|
|
274
|
+
*/
|
|
275
|
+
declare function runWithConfig(options: RunWithConfigOptions, pluginConfig: ContractsPluginConfig): Promise<void>;
|
|
276
|
+
|
|
277
|
+
export { runWithConfig as $, type ArrayType as A, isDomainEvent as B, type Command as C, type DecoratorNames as D, type EnumDefinition as E, type FileSystem as F, isFunctionType as G, isIntersectionType as H, type InputContextConfig as I, isLiteralType as J, isObjectType as K, type LiteralType as L, type MessageType as M, isPrimitiveType 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, isReferenceType as V, isTupleType as W, isUnionType as X, nodeFileSystem as Y, type RunWithConfigOptions as Z, run as _, type DomainEvent as a, ContextConfig as b, type ContractsPluginConfig as c, type ClassDefinition as d, type ClassImport as e, type Config as f, type Dependency as g, type DependencyKind as h, type EnumMember as i, type ExtractionError as j, type ExtractionResult as k, type ExtractionWarning as l, type Field as m, type FileStats as n, type FunctionParameter as o, type FunctionType as p, type ImportSource as q, type IntersectionType as r, type Message as s, type MessageBase as t, type ReferenceType as u, type TupleType as v, type TypeDefinitionKind as w, type TypeRef as x, isArrayType as y, isCommand as z };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,36 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Options for runWithConfig when config is provided directly.
|
|
5
|
-
*/
|
|
6
|
-
export interface RunWithConfigOptions {
|
|
7
|
-
outputDir: string;
|
|
8
|
-
messageTypes?: MessageType[];
|
|
9
|
-
generateMessageRegistry?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Plugin configuration structure for contracts generator.
|
|
13
|
-
* This is the config passed from hexai.config.ts.
|
|
14
|
-
*/
|
|
15
|
-
export interface ContractsPluginConfig {
|
|
16
|
-
contexts: Array<{
|
|
17
|
-
name: string;
|
|
18
|
-
sourceDir: string;
|
|
19
|
-
tsconfigPath?: string;
|
|
20
|
-
}>;
|
|
21
|
-
pathAliasRewrites?: Record<string, string>;
|
|
22
|
-
externalDependencies?: Record<string, string>;
|
|
23
|
-
decoratorNames?: DecoratorNames;
|
|
24
|
-
responseNamingConventions?: ResponseNamingConvention[];
|
|
25
|
-
removeDecorators?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare function run(args: string[]): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Run contracts generator with config provided directly.
|
|
30
|
-
* This is used by the hexai CLI integration where config comes from hexai.config.ts.
|
|
31
|
-
*
|
|
32
|
-
* @param options - CLI options (outputDir, messageTypes, generateMessageRegistry)
|
|
33
|
-
* @param pluginConfig - Plugin configuration from hexai.config.ts
|
|
34
|
-
*/
|
|
35
|
-
export declare function runWithConfig(options: RunWithConfigOptions, pluginConfig: ContractsPluginConfig): Promise<void>;
|
|
36
|
-
//# sourceMappingURL=cli.d.ts.map
|
|
2
|
+
export { c as ContractsPluginConfig, Z as RunWithConfigOptions, _ as run, $ as runWithConfig } from './cli-DajurpEQ.js';
|