@hexaijs/plugin-contracts-generator 0.2.1 → 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/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 +223 -2471
- 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 -459
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -2712
- 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 -60
- package/dist/cli-DajurpEQ.d.ts +0 -277
package/dist/index.d.ts
CHANGED
|
@@ -1,461 +1,41 @@
|
|
|
1
|
-
import { F as FileSystem, D as DecoratorNames, M as MessageType, R as ResponseNamingConvention, S as SourceFile, a as DomainEvent, C as Command, Q as Query, T as TypeDefinition, b as ContextConfig, I as InputContextConfig, c as ContractsPluginConfig } from './cli-DajurpEQ.js';
|
|
2
|
-
export { A as ArrayType, d as ClassDefinition, e as ClassImport, f as Config, g as Dependency, h as DependencyKind, E as EnumDefinition, i as EnumMember, j as ExtractionError, k as ExtractionResult, l as ExtractionWarning, m as Field, n as FileStats, o as FunctionParameter, p as FunctionType, q as ImportSource, r as IntersectionType, L as LiteralType, s as Message, t as MessageBase, O as ObjectType, P as PrimitiveType, u as ReferenceType, v as TupleType, w as TypeDefinitionKind, x as TypeRef, U as UnionType, y as isArrayType, z as isCommand, B as isDomainEvent, G as isFunctionType, H as isIntersectionType, J as isLiteralType, K as isObjectType, N as isPrimitiveType, V as isReferenceType, W as isTupleType, X as isUnionType, Y as nodeFileSystem } from './cli-DajurpEQ.js';
|
|
3
|
-
export { PublicCommand, PublicCommandOptions, PublicEvent, PublicEventOptions, PublicQuery, PublicQueryOptions } from '@hexaijs/contracts/decorators';
|
|
4
|
-
import { HexaiCliPlugin } from '@hexaijs/cli';
|
|
5
|
-
|
|
6
|
-
interface ScannerOptions {
|
|
7
|
-
exclude?: string[];
|
|
8
|
-
fileSystem?: FileSystem;
|
|
9
|
-
decoratorNames?: DecoratorNames;
|
|
10
|
-
/**
|
|
11
|
-
* Filter which message types to scan for.
|
|
12
|
-
* Defaults to all types: ['event', 'command', 'query']
|
|
13
|
-
*/
|
|
14
|
-
messageTypes?: MessageType[];
|
|
15
|
-
}
|
|
16
|
-
declare class Scanner {
|
|
17
|
-
private readonly exclude;
|
|
18
|
-
private readonly fs;
|
|
19
|
-
private readonly decoratorPatterns;
|
|
20
|
-
constructor(options?: ScannerOptions);
|
|
21
|
-
scan(sourceDir: string): Promise<string[]>;
|
|
22
|
-
private containsPublicDecorator;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface ParseResult {
|
|
26
|
-
readonly events: readonly DomainEvent[];
|
|
27
|
-
readonly commands: readonly Command[];
|
|
28
|
-
readonly queries: readonly Query[];
|
|
29
|
-
readonly typeDefinitions: readonly TypeDefinition[];
|
|
30
|
-
}
|
|
31
|
-
interface ParserOptions {
|
|
32
|
-
decoratorNames?: DecoratorNames;
|
|
33
|
-
responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
34
|
-
messageTypes?: readonly MessageType[];
|
|
35
|
-
}
|
|
36
|
-
declare class Parser {
|
|
37
|
-
private readonly decoratorMappings;
|
|
38
|
-
private readonly responseNamingConventions;
|
|
39
|
-
private readonly messageTypes;
|
|
40
|
-
constructor(options?: ParserOptions);
|
|
41
|
-
parse(sourceCode: string, sourceFileInfo: SourceFile): ParseResult;
|
|
42
|
-
private collectMessagesFromClass;
|
|
43
|
-
private applyNamingConventionMatching;
|
|
44
|
-
private findMatchingResponseType;
|
|
45
|
-
private buildMessage;
|
|
46
|
-
private extractMessageDetails;
|
|
47
|
-
private extractPayload;
|
|
48
|
-
private parsePayloadTypeArgument;
|
|
49
|
-
private flattenIntersectionToFields;
|
|
50
|
-
private extractTypeDefinition;
|
|
51
|
-
private extractInterfaceDefinition;
|
|
52
|
-
private buildTypeDefinition;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface ImportInfo {
|
|
56
|
-
moduleSpecifier: string;
|
|
57
|
-
resolvedPath: string | null;
|
|
58
|
-
isExternal: boolean;
|
|
59
|
-
importedNames: string[];
|
|
60
|
-
}
|
|
61
|
-
interface FileNode {
|
|
62
|
-
absolutePath: string;
|
|
63
|
-
relativePath: string;
|
|
64
|
-
imports: ImportInfo[];
|
|
65
|
-
isEntryPoint: boolean;
|
|
66
|
-
}
|
|
67
|
-
interface FileGraph {
|
|
68
|
-
nodes: Map<string, FileNode>;
|
|
69
|
-
entryPoints: Set<string>;
|
|
70
|
-
excludedPaths: Set<string>;
|
|
71
|
-
}
|
|
72
|
-
interface FileGraphResolverOptions {
|
|
73
|
-
contextConfig: ContextConfig;
|
|
74
|
-
fileSystem?: FileSystem;
|
|
75
|
-
excludeDependencies?: string[];
|
|
76
|
-
}
|
|
77
|
-
declare class FileGraphResolver {
|
|
78
|
-
private readonly contextConfig;
|
|
79
|
-
private readonly fs;
|
|
80
|
-
private readonly excludeDependencies;
|
|
81
|
-
private constructor();
|
|
82
|
-
static create(options: FileGraphResolverOptions): FileGraphResolver;
|
|
83
|
-
buildGraph(entryPoints: string[], sourceRoot: string): Promise<FileGraph>;
|
|
84
|
-
private extractImports;
|
|
85
|
-
private readSourceFile;
|
|
86
|
-
private extractModuleSpecifier;
|
|
87
|
-
private extractImportedNamesFromNode;
|
|
88
|
-
private resolveModule;
|
|
89
|
-
private queueUnvisitedLocalDependencies;
|
|
90
|
-
private shouldExclude;
|
|
91
|
-
private resolveRelativeModule;
|
|
92
|
-
private tryResolveWithExtensions;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface CopyOptions {
|
|
96
|
-
sourceRoot: string;
|
|
97
|
-
outputDir: string;
|
|
98
|
-
fileGraph: FileGraph;
|
|
99
|
-
pathAliasRewrites?: Map<string, string>;
|
|
100
|
-
removeDecorators?: boolean;
|
|
101
|
-
responseTypesToExport?: Map<string, string[]>;
|
|
102
|
-
messageTypes?: readonly MessageType[];
|
|
103
|
-
decoratorNames?: DecoratorNames;
|
|
104
|
-
}
|
|
105
|
-
interface CopyResult {
|
|
106
|
-
copiedFiles: string[];
|
|
107
|
-
rewrittenImports: Map<string, string[]>;
|
|
108
|
-
}
|
|
109
|
-
interface FileCopierOptions {
|
|
110
|
-
fileSystem?: FileSystem;
|
|
111
|
-
}
|
|
112
|
-
declare class FileCopier {
|
|
113
|
-
private readonly fs;
|
|
114
|
-
constructor(options?: FileCopierOptions);
|
|
115
|
-
copyFiles(options: CopyOptions): Promise<CopyResult>;
|
|
116
|
-
private preprocessEntryFiles;
|
|
117
|
-
private expandTransitiveDependencies;
|
|
118
|
-
private resolveNodeContent;
|
|
119
|
-
private applyTransformations;
|
|
120
|
-
generateBarrelExport(copiedFiles: string[], outputDir: string): string;
|
|
121
|
-
private readFileContent;
|
|
122
|
-
private writeOutputFile;
|
|
123
|
-
private processExcludedImports;
|
|
124
|
-
private processDecoratorRemoval;
|
|
125
|
-
private processTypeExports;
|
|
126
|
-
private processInternalPathAliases;
|
|
127
|
-
private processExternalPathAliases;
|
|
128
|
-
private createExportStatement;
|
|
129
|
-
private rewriteInternalPathAliases;
|
|
130
|
-
private isExternalOrRelativeImport;
|
|
131
|
-
private resolveInternalImport;
|
|
132
|
-
private rewriteModuleSpecifier;
|
|
133
|
-
private computeRelativePath;
|
|
134
|
-
private applyPathAliasRewrites;
|
|
135
|
-
private escapeRegex;
|
|
136
|
-
private removeExcludedImports;
|
|
137
|
-
private findExcludedModuleSpecifiers;
|
|
138
|
-
private createExcludedImportsVisitor;
|
|
139
|
-
private isImportFromExcludedModule;
|
|
140
|
-
private isExportFromExcludedModule;
|
|
141
|
-
private removeContractDecorators;
|
|
142
|
-
private createDecoratorRemovalVisitor;
|
|
143
|
-
private processContractGeneratorImport;
|
|
144
|
-
private createImportWithFilteredBindings;
|
|
145
|
-
private removeContractDecoratorsFromClass;
|
|
146
|
-
private extractDecoratorName;
|
|
147
|
-
private isDecoratorCallExpression;
|
|
148
|
-
private hasExportModifier;
|
|
149
|
-
private prependExportModifier;
|
|
150
|
-
private addExportToTypes;
|
|
151
|
-
private createExportAdditionVisitor;
|
|
152
|
-
private addExportToTypeAlias;
|
|
153
|
-
private addExportToInterface;
|
|
154
|
-
private transformSourceFile;
|
|
155
|
-
private extractSymbolsFromEntry;
|
|
156
|
-
private buildDecoratorToMessageTypeMap;
|
|
157
|
-
private findTargetClasses;
|
|
158
|
-
private computeRelatedTypeNames;
|
|
159
|
-
private collectUsedIdentifiers;
|
|
160
|
-
private collectDecoratorIdentifier;
|
|
161
|
-
private collectLocalTypeDeclarations;
|
|
162
|
-
private addToDeclarationMap;
|
|
163
|
-
private resolveIncludedLocalTypes;
|
|
164
|
-
private collectTypeIdentifiersFromNodes;
|
|
165
|
-
private collectComputedPropertyIdentifier;
|
|
166
|
-
private generateExtractedOutput;
|
|
167
|
-
private buildImportMap;
|
|
168
|
-
private filterImports;
|
|
169
|
-
private appendImportStatements;
|
|
170
|
-
private appendLocalTypeDeclarations;
|
|
171
|
-
private appendTargetClasses;
|
|
172
|
-
private appendNodeWithExport;
|
|
173
|
-
private nodeHasExportKeyword;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Base error class for all contracts-generator errors.
|
|
178
|
-
* Allows catching all library errors with `instanceof MessageParserError`.
|
|
179
|
-
*/
|
|
180
|
-
declare class MessageParserError extends Error {
|
|
181
|
-
constructor(message: string, options?: ErrorOptions);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Base class for configuration-related errors.
|
|
185
|
-
*/
|
|
186
|
-
declare class ConfigurationError extends MessageParserError {
|
|
187
|
-
constructor(message: string, options?: ErrorOptions);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Error thrown when loading application.config.ts fails.
|
|
191
|
-
*/
|
|
192
|
-
declare class ConfigLoadError extends ConfigurationError {
|
|
193
|
-
constructor(message: string, options?: ErrorOptions);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Base class for file system operation errors.
|
|
197
|
-
*/
|
|
198
|
-
declare class FileSystemError extends MessageParserError {
|
|
199
|
-
readonly path: string;
|
|
200
|
-
constructor(message: string, path: string, options?: ErrorOptions);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Error thrown when a required file is not found.
|
|
204
|
-
*/
|
|
205
|
-
declare class FileNotFoundError extends FileSystemError {
|
|
206
|
-
constructor(path: string, options?: ErrorOptions);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Error thrown when reading a file fails.
|
|
210
|
-
*/
|
|
211
|
-
declare class FileReadError extends FileSystemError {
|
|
212
|
-
constructor(path: string, options?: ErrorOptions);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Error thrown when writing a file fails.
|
|
216
|
-
*/
|
|
217
|
-
declare class FileWriteError extends FileSystemError {
|
|
218
|
-
constructor(path: string, options?: ErrorOptions);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Base class for parsing errors.
|
|
222
|
-
*/
|
|
223
|
-
declare class ParseError extends MessageParserError {
|
|
224
|
-
constructor(message: string, options?: ErrorOptions);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Error thrown when JSON parsing fails.
|
|
228
|
-
*/
|
|
229
|
-
declare class JsonParseError extends ParseError {
|
|
230
|
-
readonly filePath?: string;
|
|
231
|
-
constructor(message: string, filePath?: string, options?: ErrorOptions);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Base class for module/path resolution errors.
|
|
235
|
-
*/
|
|
236
|
-
declare class ResolutionError extends MessageParserError {
|
|
237
|
-
constructor(message: string, options?: ErrorOptions);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Error thrown when module resolution fails.
|
|
241
|
-
*/
|
|
242
|
-
declare class ModuleResolutionError extends ResolutionError {
|
|
243
|
-
readonly moduleSpecifier: string;
|
|
244
|
-
readonly fromFile: string;
|
|
245
|
-
constructor(moduleSpecifier: string, fromFile: string, options?: ErrorOptions);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
interface ContractsConfig {
|
|
249
|
-
readonly contexts: readonly ContextConfig[];
|
|
250
|
-
readonly pathAliasRewrites?: Readonly<Record<string, string>>;
|
|
251
|
-
readonly externalDependencies?: Readonly<Record<string, string>>;
|
|
252
|
-
readonly decoratorNames: Required<DecoratorNames>;
|
|
253
|
-
readonly responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
254
|
-
readonly removeDecorators?: boolean;
|
|
255
|
-
}
|
|
256
|
-
interface ConfigLoaderOptions {
|
|
257
|
-
fileSystem?: FileSystem;
|
|
258
|
-
}
|
|
259
|
-
declare function resolveContextEntries(entries: readonly (string | InputContextConfig)[], configDir: string, fs?: FileSystem): Promise<ContextConfig[]>;
|
|
260
|
-
declare class ConfigLoader {
|
|
261
|
-
private readonly fs;
|
|
262
|
-
constructor(options?: ConfigLoaderOptions);
|
|
263
|
-
load(configPath: string): Promise<ContractsConfig>;
|
|
264
|
-
private loadTypeScriptConfig;
|
|
265
|
-
private extractContractsConfig;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface RegistryGeneratorOptions {
|
|
269
|
-
readonly messageRegistryImport: string;
|
|
270
|
-
readonly useNamespace?: boolean;
|
|
271
|
-
}
|
|
272
|
-
interface ContextMessages {
|
|
273
|
-
readonly contextName: string;
|
|
274
|
-
readonly events: readonly DomainEvent[];
|
|
275
|
-
readonly commands: readonly Command[];
|
|
276
|
-
readonly queries?: readonly Query[];
|
|
277
|
-
readonly importPath?: string;
|
|
278
|
-
}
|
|
279
|
-
declare class RegistryGenerator {
|
|
280
|
-
private readonly options;
|
|
281
|
-
constructor(options?: Partial<RegistryGeneratorOptions>);
|
|
282
|
-
generate(contexts: readonly ContextMessages[]): string;
|
|
283
|
-
private generateEmptyRegistry;
|
|
284
|
-
private generateWithNamespace;
|
|
285
|
-
private getNamespaceInfos;
|
|
286
|
-
private generateNamespaceImports;
|
|
287
|
-
private generateNamespaceExports;
|
|
288
|
-
private generateNamespaceRegistrations;
|
|
289
|
-
private toNamespace;
|
|
290
|
-
private generateImports;
|
|
291
|
-
private generateRegistrations;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
1
|
/**
|
|
295
|
-
*
|
|
296
|
-
*/
|
|
297
|
-
interface RewrittenImport {
|
|
298
|
-
/** The rewritten module specifier (e.g., "@libera/contracts/common/request") */
|
|
299
|
-
readonly rewrittenPath: string;
|
|
300
|
-
/** The original module specifier before rewrite (e.g., "@libera/common/request") */
|
|
301
|
-
readonly originalPath: string;
|
|
302
|
-
/** The imported symbol names */
|
|
303
|
-
readonly symbols: readonly string[];
|
|
304
|
-
/** Whether this is a type-only import */
|
|
305
|
-
readonly isTypeOnly: boolean;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Represents a re-export file to be generated
|
|
309
|
-
*/
|
|
310
|
-
interface ReexportFile {
|
|
311
|
-
/** Relative path within contracts output dir (e.g., "common/request.ts") */
|
|
312
|
-
readonly relativePath: string;
|
|
313
|
-
/** The original module to re-export from */
|
|
314
|
-
readonly originalModule: string;
|
|
315
|
-
/** Symbols to re-export */
|
|
316
|
-
readonly symbols: readonly string[];
|
|
317
|
-
/** Whether all symbols are type-only */
|
|
318
|
-
readonly isTypeOnly: boolean;
|
|
319
|
-
}
|
|
320
|
-
interface ReexportGeneratorOptions {
|
|
321
|
-
fileSystem?: FileSystem;
|
|
322
|
-
}
|
|
323
|
-
interface AnalyzeOptions {
|
|
324
|
-
/** The files to analyze (absolute paths) */
|
|
325
|
-
readonly files: readonly string[];
|
|
326
|
-
/** Map of original path prefix -> rewritten path prefix */
|
|
327
|
-
readonly pathAliasRewrites: ReadonlyMap<string, string>;
|
|
328
|
-
}
|
|
329
|
-
interface GenerateOptions {
|
|
330
|
-
/** The output directory for re-export files */
|
|
331
|
-
readonly outputDir: string;
|
|
332
|
-
/** The re-export files to generate */
|
|
333
|
-
readonly reexportFiles: readonly ReexportFile[];
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Generates re-export files for pathAliasRewrites
|
|
337
|
-
*/
|
|
338
|
-
declare class ReexportGenerator {
|
|
339
|
-
private readonly fs;
|
|
340
|
-
constructor(options?: ReexportGeneratorOptions);
|
|
341
|
-
/**
|
|
342
|
-
* Analyzes files to find imports that match pathAliasRewrites
|
|
343
|
-
* and groups them by rewritten path
|
|
344
|
-
*/
|
|
345
|
-
analyze(options: AnalyzeOptions): Promise<ReexportFile[]>;
|
|
346
|
-
/**
|
|
347
|
-
* Generates re-export files
|
|
348
|
-
*/
|
|
349
|
-
generate(options: GenerateOptions): Promise<string[]>;
|
|
350
|
-
/**
|
|
351
|
-
* Extracts imports from source content that match rewritten prefixes
|
|
352
|
-
*/
|
|
353
|
-
private extractRewrittenImports;
|
|
354
|
-
/**
|
|
355
|
-
* Extracts symbol names from import clause
|
|
356
|
-
*/
|
|
357
|
-
private extractSymbolNames;
|
|
358
|
-
/**
|
|
359
|
-
* Groups imports by rewritten path and merges symbols
|
|
360
|
-
*/
|
|
361
|
-
private groupImportsByPath;
|
|
362
|
-
/**
|
|
363
|
-
* Converts a rewritten package path to a relative file path
|
|
364
|
-
* e.g., "@libera/contracts/common/request" with prefix "@libera/contracts"
|
|
365
|
-
* -> "common/request.ts"
|
|
366
|
-
*/
|
|
367
|
-
private rewrittenPathToRelativePath;
|
|
368
|
-
/**
|
|
369
|
-
* Generates the content for a re-export file
|
|
370
|
-
*/
|
|
371
|
-
private generateReexportContent;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
375
|
-
interface Logger {
|
|
376
|
-
debug(message: string): void;
|
|
377
|
-
info(message: string): void;
|
|
378
|
-
warn(message: string): void;
|
|
379
|
-
error(message: string): void;
|
|
380
|
-
}
|
|
381
|
-
interface ConsoleLoggerOptions {
|
|
382
|
-
level?: LogLevel;
|
|
383
|
-
}
|
|
384
|
-
declare class ConsoleLogger implements Logger {
|
|
385
|
-
private readonly level;
|
|
386
|
-
constructor(options?: ConsoleLoggerOptions);
|
|
387
|
-
debug(message: string): void;
|
|
388
|
-
info(message: string): void;
|
|
389
|
-
warn(message: string): void;
|
|
390
|
-
error(message: string): void;
|
|
391
|
-
private shouldLog;
|
|
392
|
-
}
|
|
393
|
-
declare const noopLogger: Logger;
|
|
394
|
-
|
|
395
|
-
interface PipelineDependencies {
|
|
396
|
-
readonly scanner: Scanner;
|
|
397
|
-
readonly parser: Parser;
|
|
398
|
-
readonly fileGraphResolver: FileGraphResolver;
|
|
399
|
-
readonly fileCopier: FileCopier;
|
|
400
|
-
readonly fileSystem: FileSystem;
|
|
401
|
-
readonly logger: Logger;
|
|
402
|
-
}
|
|
403
|
-
interface PipelineOptions {
|
|
404
|
-
readonly contextName: string;
|
|
405
|
-
readonly sourceDir: string;
|
|
406
|
-
readonly outputDir: string;
|
|
407
|
-
readonly pathAliasRewrites?: Map<string, string>;
|
|
408
|
-
readonly removeDecorators?: boolean;
|
|
409
|
-
}
|
|
410
|
-
interface PipelineResult {
|
|
411
|
-
readonly events: readonly DomainEvent[];
|
|
412
|
-
readonly commands: readonly Command[];
|
|
413
|
-
readonly queries: readonly Query[];
|
|
414
|
-
readonly copiedFiles: string[];
|
|
415
|
-
}
|
|
416
|
-
interface ParsedMessages {
|
|
417
|
-
readonly events: readonly DomainEvent[];
|
|
418
|
-
readonly commands: readonly Command[];
|
|
419
|
-
readonly queries: readonly Query[];
|
|
420
|
-
readonly typeDefinitions: readonly TypeDefinition[];
|
|
421
|
-
}
|
|
422
|
-
declare class ContractsPipeline {
|
|
423
|
-
private readonly deps;
|
|
424
|
-
private readonly messageTypes?;
|
|
425
|
-
private constructor();
|
|
426
|
-
static create(options: {
|
|
427
|
-
contextConfig: ContextConfig;
|
|
428
|
-
responseNamingConventions?: readonly ResponseNamingConvention[];
|
|
429
|
-
fileSystem?: FileSystem;
|
|
430
|
-
logger?: Logger;
|
|
431
|
-
excludeDependencies?: string[];
|
|
432
|
-
messageTypes?: MessageType[];
|
|
433
|
-
}): ContractsPipeline;
|
|
434
|
-
static fromDependencies(deps: PipelineDependencies): ContractsPipeline;
|
|
435
|
-
execute(options: PipelineOptions): Promise<PipelineResult>;
|
|
436
|
-
private collectResponseTypesToExport;
|
|
437
|
-
scan(sourceDir: string): Promise<string[]>;
|
|
438
|
-
parse(files: string[], sourceRoot: string): Promise<ParsedMessages>;
|
|
439
|
-
resolve(entryPoints: string[], sourceRoot: string): Promise<FileGraph>;
|
|
440
|
-
copy(fileGraph: FileGraph, sourceRoot: string, outputDir: string, pathAliasRewrites?: Map<string, string>, responseTypesToExport?: Map<string, string[]>, removeDecorators?: boolean, messageTypes?: readonly MessageType[]): Promise<string[]>;
|
|
441
|
-
exportBarrel(copiedFiles: string[], outputDir: string): Promise<void>;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* CLI plugin definition for hexai integration.
|
|
2
|
+
* Contracts Generator
|
|
446
3
|
*
|
|
447
|
-
*
|
|
448
|
-
* Configuration is provided via hexai.config.ts.
|
|
4
|
+
* Extract Domain Events and Commands from TypeScript source code using decorators.
|
|
449
5
|
*
|
|
450
6
|
* @example
|
|
451
|
-
* ```
|
|
452
|
-
*
|
|
453
|
-
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { extract } from '@hexaijs/plugin-contracts-generator';
|
|
9
|
+
*
|
|
10
|
+
* const result = await extract({
|
|
11
|
+
* sourceDir: 'packages',
|
|
12
|
+
* outputDir: 'packages/contracts',
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* console.log(`Extracted ${result.events.length} events and ${result.commands.length} commands`);
|
|
454
16
|
* ```
|
|
455
17
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
18
|
+
export type { SourceFile, TypeRef, PrimitiveType, ArrayType, ObjectType, UnionType, IntersectionType, ReferenceType, LiteralType, TupleType, FunctionType, FunctionParameter, Field, TypeDefinition, TypeDefinitionKind, EnumMember, EnumDefinition, ClassDefinition, ClassImport, Message, MessageBase, DomainEvent, Command, Dependency, DependencyKind, ImportSource, ExtractionResult, ExtractionError, ExtractionWarning, Config, } from "./domain/types.js";
|
|
19
|
+
export { isPrimitiveType, isArrayType, isObjectType, isUnionType, isIntersectionType, isReferenceType, isLiteralType, isTupleType, isFunctionType, isDomainEvent, isCommand, } from "./domain/types.js";
|
|
20
|
+
export { PublicEvent, PublicCommand, PublicQuery, type PublicEventOptions, type PublicCommandOptions, type PublicQueryOptions, } from "@hexaijs/contracts/decorators";
|
|
21
|
+
export { Scanner, type ScannerOptions } from "./scanner.js";
|
|
22
|
+
export { Parser, type ParseResult } from "./parser.js";
|
|
23
|
+
export { FileGraphResolver } from "./file-graph-resolver.js";
|
|
24
|
+
export { FileCopier } from "./file-copier.js";
|
|
25
|
+
export { ConfigLoader, resolveContextEntries, type ContractsConfig } from "./config-loader.js";
|
|
26
|
+
export { MessageParserError, ConfigurationError, ConfigLoadError, FileSystemError, FileNotFoundError, FileReadError, FileWriteError, ParseError, JsonParseError, ResolutionError, ModuleResolutionError, } from "./errors.js";
|
|
27
|
+
export { RegistryGenerator, type RegistryGeneratorOptions, type ContextMessages, } from "./registry-generator.js";
|
|
28
|
+
export { ReexportGenerator, type ReexportGeneratorOptions, type AnalyzeOptions, type GenerateOptions, type RewrittenImport, type ReexportFile, } from "./reexport-generator.js";
|
|
29
|
+
import { type FileSystem } from "./file-system.js";
|
|
30
|
+
import { type Logger } from "./logger.js";
|
|
31
|
+
export type { FileSystem, FileStats } from "./file-system.js";
|
|
32
|
+
export { nodeFileSystem } from "./file-system.js";
|
|
33
|
+
export type { Logger, LogLevel, ConsoleLoggerOptions } from "./logger.js";
|
|
34
|
+
export { ConsoleLogger, noopLogger } from "./logger.js";
|
|
35
|
+
export { ContractsPipeline, type PipelineDependencies, type PipelineOptions, type PipelineResult, type ParsedMessages, } from "./pipeline.js";
|
|
36
|
+
export { ContextConfig, type InputContextConfig } from "./context-config.js";
|
|
37
|
+
import type { ResponseNamingConvention, MessageType } from "./domain/types.js";
|
|
38
|
+
export interface ProcessContextOptions {
|
|
459
39
|
contextName: string;
|
|
460
40
|
path: string;
|
|
461
41
|
sourceDir?: string;
|
|
@@ -468,12 +48,12 @@ interface ProcessContextOptions {
|
|
|
468
48
|
fileSystem?: FileSystem;
|
|
469
49
|
logger?: Logger;
|
|
470
50
|
}
|
|
471
|
-
interface ProcessContextResult {
|
|
472
|
-
events: readonly DomainEvent[];
|
|
473
|
-
commands: readonly Command[];
|
|
474
|
-
queries: readonly Query[];
|
|
51
|
+
export interface ProcessContextResult {
|
|
52
|
+
events: readonly import("./domain/types.js").DomainEvent[];
|
|
53
|
+
commands: readonly import("./domain/types.js").Command[];
|
|
54
|
+
queries: readonly import("./domain/types.js").Query[];
|
|
475
55
|
copiedFiles: string[];
|
|
476
56
|
}
|
|
477
|
-
declare function processContext(options: ProcessContextOptions): Promise<ProcessContextResult>;
|
|
478
|
-
|
|
479
|
-
|
|
57
|
+
export declare function processContext(options: ProcessContextOptions): Promise<ProcessContextResult>;
|
|
58
|
+
export { cliPlugin } from "./hexai-plugin.js";
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EACR,UAAU,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,OAAO,EACP,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,MAAM,GACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,eAAe,EACf,WAAW,EACX,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,OA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