@hexaijs/plugin-contracts-generator 0.1.0
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/LICENSE +21 -0
- package/README.md +337 -0
- package/dist/ast-utils.d.ts +6 -0
- package/dist/ast-utils.d.ts.map +1 -0
- package/dist/ast-utils.js +111 -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 +155 -0
- package/dist/class-analyzer.js.map +1 -0
- package/dist/cli.d.ts +36 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +321 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-loader.d.ts +34 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +188 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/decorators/index.d.ts +143 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +123 -0
- package/dist/decorators/index.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 +18 -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 +65 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/errors.d.ts +79 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +138 -0
- package/dist/errors.js.map +1 -0
- package/dist/file-copier.d.ts +85 -0
- package/dist/file-copier.d.ts.map +1 -0
- package/dist/file-copier.js +773 -0
- package/dist/file-copier.js.map +1 -0
- package/dist/file-graph-resolver.d.ts +47 -0
- package/dist/file-graph-resolver.d.ts.map +1 -0
- package/dist/file-graph-resolver.js +230 -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 +34 -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 +59 -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 +77 -0
- package/dist/import-analyzer.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +21 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +47 -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 +209 -0
- package/dist/parser.js.map +1 -0
- package/dist/pipeline.d.ts +56 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +152 -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 +208 -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 +108 -0
- package/dist/registry-generator.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/index.js.map +1 -0
- 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 +39 -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 +53 -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 +198 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/tsconfig-loader.d.ts +8 -0
- package/dist/tsconfig-loader.d.ts.map +1 -0
- package/dist/tsconfig-loader.js +64 -0
- package/dist/tsconfig-loader.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/message-registry.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAGD,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACjC,gBAAgB,IAAI,OAAO,CAAC;IAC5B,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC;IAEtE,KAAK,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;CACxC;AAED,qBAAa,eAAe;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAE5D,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAa1C,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC;IAYtE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO;IAI7C,IAAI,IAAI,MAAM;CAGjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageRegistry = void 0;
|
|
4
|
+
class MessageRegistry {
|
|
5
|
+
registry = new Map();
|
|
6
|
+
register(messageClass) {
|
|
7
|
+
const type = messageClass.getType();
|
|
8
|
+
const version = messageClass.getSchemaVersion();
|
|
9
|
+
const key = makeKey(type, version);
|
|
10
|
+
if (this.registry.has(key)) {
|
|
11
|
+
throw new Error(`${format(type, version)} is already registered.`);
|
|
12
|
+
}
|
|
13
|
+
this.registry.set(key, messageClass);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
dehydrate(header, body) {
|
|
17
|
+
const { type, schemaVersion } = header;
|
|
18
|
+
const key = makeKey(type, schemaVersion);
|
|
19
|
+
const messageClass = this.registry.get(key);
|
|
20
|
+
if (!messageClass) {
|
|
21
|
+
throw new Error(`${format(type, schemaVersion)} is not registered.`);
|
|
22
|
+
}
|
|
23
|
+
return messageClass.from(body, header);
|
|
24
|
+
}
|
|
25
|
+
has(type, version) {
|
|
26
|
+
return this.registry.has(makeKey(type, version));
|
|
27
|
+
}
|
|
28
|
+
size() {
|
|
29
|
+
return this.registry.size;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.MessageRegistry = MessageRegistry;
|
|
33
|
+
function makeKey(type, version) {
|
|
34
|
+
return version !== undefined ? `${type}:${version}` : type;
|
|
35
|
+
}
|
|
36
|
+
function format(type, version) {
|
|
37
|
+
return version !== undefined ? `'${type}' (v${version})` : `'${type}'`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=message-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-registry.js","sourceRoot":"","sources":["../../src/runtime/message-registry.ts"],"names":[],"mappings":";;;AAmBA,MAAa,eAAe;IACP,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE5D,QAAQ,CAAC,YAA0B;QAC/B,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QACpC,MAAM,OAAO,G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C,IAAI,CAAC;AAC/D,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,OAAiB;IAC3C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FileSystem } from "./file-system";
|
|
2
|
+
import type { DecoratorNames, MessageType } from "./domain";
|
|
3
|
+
export interface ScannerOptions {
|
|
4
|
+
exclude?: string[];
|
|
5
|
+
fileSystem?: FileSystem;
|
|
6
|
+
decoratorNames?: DecoratorNames;
|
|
7
|
+
/**
|
|
8
|
+
* Filter which message types to scan for.
|
|
9
|
+
* Defaults to all types: ['event', 'command', 'query']
|
|
10
|
+
*/
|
|
11
|
+
messageTypes?: MessageType[];
|
|
12
|
+
}
|
|
13
|
+
export declare class Scanner {
|
|
14
|
+
private readonly exclude;
|
|
15
|
+
private readonly fs;
|
|
16
|
+
private readonly decoratorPatterns;
|
|
17
|
+
constructor(options?: ScannerOptions);
|
|
18
|
+
scan(sourceDir: string): Promise<string[]>;
|
|
19
|
+
private containsPublicDecorator;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAW5D,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAChC;AAED,qBAAa,OAAO;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAW;gBAEjC,OAAO,GAAE,cAAmB;IAalC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAsBhD,OAAO,CAAC,uBAAuB;CAGlC"}
|
package/dist/scanner.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scanner = void 0;
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const file_system_1 = require("./file-system");
|
|
7
|
+
const domain_1 = require("./domain");
|
|
8
|
+
const DEFAULT_EXCLUDE_PATTERNS = [
|
|
9
|
+
"**/node_modules/**",
|
|
10
|
+
"**/dist/**",
|
|
11
|
+
"**/*.d.ts",
|
|
12
|
+
"**/*.test.ts",
|
|
13
|
+
"**/*.spec.ts",
|
|
14
|
+
];
|
|
15
|
+
class Scanner {
|
|
16
|
+
exclude;
|
|
17
|
+
fs;
|
|
18
|
+
decoratorPatterns;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.exclude = options.exclude ?? DEFAULT_EXCLUDE_PATTERNS;
|
|
21
|
+
this.fs = options.fileSystem ?? file_system_1.nodeFileSystem;
|
|
22
|
+
const names = (0, domain_1.mergeDecoratorNames)(options.decoratorNames);
|
|
23
|
+
const messageTypes = options.messageTypes ?? ['event', 'command', 'query'];
|
|
24
|
+
this.decoratorPatterns = messageTypes.map((type) => {
|
|
25
|
+
const decoratorName = names[type];
|
|
26
|
+
return `@${decoratorName}(`;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async scan(sourceDir) {
|
|
30
|
+
const files = await (0, glob_1.glob)(`${sourceDir}/**/*.ts`, {
|
|
31
|
+
ignore: this.exclude,
|
|
32
|
+
});
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
let content;
|
|
36
|
+
try {
|
|
37
|
+
content = await this.fs.readFile(file);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new errors_1.FileReadError(file, { cause: error });
|
|
41
|
+
}
|
|
42
|
+
if (this.containsPublicDecorator(content)) {
|
|
43
|
+
result.push(file);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
containsPublicDecorator(content) {
|
|
49
|
+
return this.decoratorPatterns.some(pattern => content.includes(pattern));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Scanner = Scanner;
|
|
53
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,qCAAyC;AACzC,+CAA2D;AAE3D,qCAA+C;AAE/C,MAAM,wBAAwB,GAAG;IAC7B,oBAAoB;IACpB,YAAY;IACZ,WAAW;IACX,cAAc;IACd,cAAc;CACjB,CAAC;AAaF,MAAa,OAAO;IACC,OAAO,CAAW;IAClB,EAAE,CAAa;IACf,iBAAiB,CAAW;IAE7C,YAAY,UAA0B,EAAE;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,wBAAwB,CAAC;QAC3D,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,UAAU,IAAI,4BAAc,CAAC;QAE/C,MAAM,KAAK,GAAG,IAAA,4BAAmB,EAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE3E,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,IAAI,aAAa,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB;QACxB,MAAM,KAAK,GAAG,MAAM,IAAA,WAAI,EAAC,GAAG,SAAS,UAAU,EAAE;YAC7C,MAAM,EAAE,IAAI,CAAC,OAAO;SACvB,CAAC,CAAC;QACH,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,OAAe,CAAC;YACpB,IAAI,CAAC;gBACD,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,MAAM,IAAI,sBAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACpD,CAAC;YAED,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,uBAAuB,CAAC,OAAe;QAC3C,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7E,CAAC;CACJ;AA3CD,0BA2CC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SourceFile, TypeDefinition, DomainEvent, Command, PrimitiveType, Field, ClassDefinition, ClassImport } from "./domain";
|
|
2
|
+
import type { FileSystem } from "./file-system";
|
|
3
|
+
export declare function createSourceFile(path?: string, absolutePath?: string): SourceFile;
|
|
4
|
+
export declare function createTypeDefinition(name: string, sourceFileOrBody?: SourceFile | TypeDefinition["body"], bodyArg?: TypeDefinition["body"]): TypeDefinition;
|
|
5
|
+
export declare function createEventWithReferenceField(eventName: string, fieldName: string, referencedTypeName: string): DomainEvent;
|
|
6
|
+
export declare function createCommandWithReferenceField(commandName: string, fieldName: string, referencedTypeName: string): Command;
|
|
7
|
+
export declare function createEventWithPrimitiveField(eventName: string, fieldName: string, primitiveName: PrimitiveType["name"]): DomainEvent;
|
|
8
|
+
export declare function createField(name: string, type: Field["type"], optional?: boolean, readonly?: boolean): Field;
|
|
9
|
+
export interface CreateClassDefinitionOptions {
|
|
10
|
+
sourceFile?: SourceFile;
|
|
11
|
+
baseClass?: string;
|
|
12
|
+
imports?: ClassImport[];
|
|
13
|
+
dependencies?: string[];
|
|
14
|
+
exported?: boolean;
|
|
15
|
+
sourceText?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function createClassDefinition(name: string, options?: CreateClassDefinitionOptions): ClassDefinition;
|
|
18
|
+
export interface InMemoryFileSystem extends FileSystem {
|
|
19
|
+
files: Map<string, string>;
|
|
20
|
+
directories: Set<string>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createInMemoryFileSystem(): InMemoryFileSystem;
|
|
23
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,UAAU,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACP,aAAa,EAEb,KAAK,EACL,eAAe,EACf,WAAW,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAE3D,wBAAgB,gBAAgB,CAC5B,IAAI,GAAE,MAAkB,EACxB,YAAY,CAAC,EAAE,MAAM,GACtB,UAAU,CAKZ;AAeD,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,M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@@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSourceFile = createSourceFile;
|
|
4
|
+
exports.createTypeDefinition = createTypeDefinition;
|
|
5
|
+
exports.createEventWithReferenceField = createEventWithReferenceField;
|
|
6
|
+
exports.createCommandWithReferenceField = createCommandWithReferenceField;
|
|
7
|
+
exports.createEventWithPrimitiveField = createEventWithPrimitiveField;
|
|
8
|
+
exports.createField = createField;
|
|
9
|
+
exports.createClassDefinition = createClassDefinition;
|
|
10
|
+
exports.createInMemoryFileSystem = createInMemoryFileSystem;
|
|
11
|
+
function createSourceFile(path = "test.ts", absolutePath) {
|
|
12
|
+
return {
|
|
13
|
+
absolutePath: absolutePath ?? `/project/src/${path}`,
|
|
14
|
+
relativePath: path,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function isSourceFile(obj) {
|
|
18
|
+
return (typeof obj === "object" &&
|
|
19
|
+
obj !== null &&
|
|
20
|
+
"absolutePath" in obj &&
|
|
21
|
+
"relativePath" in obj);
|
|
22
|
+
}
|
|
23
|
+
function isTypeRefBody(obj) {
|
|
24
|
+
return typeof obj === "object" && obj !== null && "kind" in obj;
|
|
25
|
+
}
|
|
26
|
+
function createTypeDefinition(name, sourceFileOrBody, bodyArg) {
|
|
27
|
+
let sourceFile;
|
|
28
|
+
let body;
|
|
29
|
+
if (sourceFileOrBody === undefined) {
|
|
30
|
+
// createTypeDefinition(name)
|
|
31
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
32
|
+
body = { kind: "primitive", name: "string" };
|
|
33
|
+
}
|
|
34
|
+
else if (isSourceFile(sourceFileOrBody)) {
|
|
35
|
+
// createTypeDefinition(name, sourceFile) or createTypeDefinition(name, sourceFile, body)
|
|
36
|
+
sourceFile = sourceFileOrBody;
|
|
37
|
+
body =
|
|
38
|
+
bodyArg ?? { kind: "primitive", name: "string" };
|
|
39
|
+
}
|
|
40
|
+
else if (isTypeRefBody(sourceFileOrBody)) {
|
|
41
|
+
// createTypeDefinition(name, body)
|
|
42
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
43
|
+
body = sourceFileOrBody;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Fallback to defaults
|
|
47
|
+
sourceFile = createSourceFile(`${name}.ts`);
|
|
48
|
+
body = { kind: "primitive", name: "string" };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
kind: "type",
|
|
53
|
+
sourceFile,
|
|
54
|
+
body,
|
|
55
|
+
exported: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function createEventWithReferenceField(eventName, fieldName, referencedTypeName) {
|
|
59
|
+
return {
|
|
60
|
+
messageType: "event",
|
|
61
|
+
name: eventName,
|
|
62
|
+
sourceFile: createSourceFile("events.ts"),
|
|
63
|
+
fields: [
|
|
64
|
+
{
|
|
65
|
+
name: fieldName,
|
|
66
|
+
type: {
|
|
67
|
+
kind: "reference",
|
|
68
|
+
name: referencedTypeName,
|
|
69
|
+
},
|
|
70
|
+
optional: false,
|
|
71
|
+
readonly: true,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
sourceText: `export class ${eventName} extends Message<{ ${fieldName}: ${referencedTypeName} }> {}`,
|
|
75
|
+
imports: [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createCommandWithReferenceField(commandName, fieldName, referencedTypeName) {
|
|
79
|
+
return {
|
|
80
|
+
messageType: "command",
|
|
81
|
+
name: commandName,
|
|
82
|
+
sourceFile: createSourceFile("commands.ts"),
|
|
83
|
+
fields: [
|
|
84
|
+
{
|
|
85
|
+
name: fieldName,
|
|
86
|
+
type: {
|
|
87
|
+
kind: "reference",
|
|
88
|
+
name: referencedTypeName,
|
|
89
|
+
},
|
|
90
|
+
optional: false,
|
|
91
|
+
readonly: true,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
sourceText: `export class ${commandName} extends Message<{ ${fieldName}: ${referencedTypeName} }> {}`,
|
|
95
|
+
imports: [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function createEventWithPrimitiveField(eventName, fieldName, primitiveName) {
|
|
99
|
+
return {
|
|
100
|
+
messageType: "event",
|
|
101
|
+
name: eventName,
|
|
102
|
+
sourceFile: createSourceFile("events.ts"),
|
|
103
|
+
fields: [
|
|
104
|
+
{
|
|
105
|
+
name: fieldName,
|
|
106
|
+
type: {
|
|
107
|
+
kind: "primitive",
|
|
108
|
+
name: primitiveName,
|
|
109
|
+
},
|
|
110
|
+
optional: false,
|
|
111
|
+
readonly: true,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
sourceText: `export class ${eventName} extends Message<{ ${fieldName}: ${primitiveName} }> {}`,
|
|
115
|
+
imports: [],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function createField(name, type, optional = false, readonly = false) {
|
|
119
|
+
return {
|
|
120
|
+
name,
|
|
121
|
+
type,
|
|
122
|
+
optional,
|
|
123
|
+
readonly,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function createClassDefinition(name, options = {}) {
|
|
127
|
+
const sourceFile = options.sourceFile ?? createSourceFile(`${name}.ts`);
|
|
128
|
+
const sourceText = options.sourceText ?? `export class ${name} { constructor() {} }`;
|
|
129
|
+
return {
|
|
130
|
+
name,
|
|
131
|
+
kind: "class",
|
|
132
|
+
sourceFile,
|
|
133
|
+
sourceText,
|
|
134
|
+
imports: options.imports ?? [],
|
|
135
|
+
dependencies: options.dependencies ?? [],
|
|
136
|
+
baseClass: options.baseClass,
|
|
137
|
+
exported: options.exported ?? true,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function createInMemoryFileSystem() {
|
|
141
|
+
const files = new Map();
|
|
142
|
+
const directories = new Set();
|
|
143
|
+
return {
|
|
144
|
+
files,
|
|
145
|
+
directories,
|
|
146
|
+
async readFile(filePath) {
|
|
147
|
+
const content = files.get(filePath);
|
|
148
|
+
if (content === undefined) {
|
|
149
|
+
throw new Error(`File not found: ${filePath}`);
|
|
150
|
+
}
|
|
151
|
+
return content;
|
|
152
|
+
},
|
|
153
|
+
async readdir(dirPath) {
|
|
154
|
+
const entries = [];
|
|
155
|
+
const normalizedDir = dirPath.endsWith("/") ? dirPath : dirPath + "/";
|
|
156
|
+
for (const filePath of files.keys()) {
|
|
157
|
+
if (filePath.startsWith(normalizedDir)) {
|
|
158
|
+
const relativePath = filePath.slice(normalizedDir.length);
|
|
159
|
+
const firstPart = relativePath.split("/")[0];
|
|
160
|
+
if (firstPart && !entries.includes(firstPart)) {
|
|
161
|
+
entries.push(firstPart);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const dir of directories) {
|
|
166
|
+
if (dir.startsWith(normalizedDir)) {
|
|
167
|
+
const relativePath = dir.slice(normalizedDir.length);
|
|
168
|
+
const firstPart = relativePath.split("/")[0];
|
|
169
|
+
if (firstPart && !entries.includes(firstPart)) {
|
|
170
|
+
entries.push(firstPart);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return entries;
|
|
175
|
+
},
|
|
176
|
+
async writeFile(filePath, content) {
|
|
177
|
+
files.set(filePath, content);
|
|
178
|
+
},
|
|
179
|
+
async mkdir(dirPath, _options) {
|
|
180
|
+
directories.add(dirPath);
|
|
181
|
+
},
|
|
182
|
+
async exists(filePath) {
|
|
183
|
+
return files.has(filePath) || directories.has(filePath);
|
|
184
|
+
},
|
|
185
|
+
async stat(filePath) {
|
|
186
|
+
const isDir = directories.has(filePath);
|
|
187
|
+
const isFile = files.has(filePath);
|
|
188
|
+
if (!isDir && !isFile) {
|
|
189
|
+
throw new Error(`Path not found: ${filePath}`);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
isDirectory: () => isDir,
|
|
193
|
+
isFile: () => isFile,
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
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ACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig-loader.d.ts","sourceRoot":"","sources":["../src/tsconfig-loader.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACzC;AAED,qBAAa,cAAc;IACjB,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAwC7D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TsconfigLoader = void 0;
|
|
37
|
+
const ts = __importStar(require("typescript"));
|
|
38
|
+
const path_1 = require("path");
|
|
39
|
+
class TsconfigLoader {
|
|
40
|
+
async load(tsconfigPath) {
|
|
41
|
+
const absolutePath = (0, path_1.resolve)(tsconfigPath);
|
|
42
|
+
const configDir = (0, path_1.dirname)(absolutePath);
|
|
43
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(absolutePath, {}, {
|
|
44
|
+
...ts.sys,
|
|
45
|
+
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
46
|
+
throw new Error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!parsed) {
|
|
50
|
+
throw new Error(`Failed to parse tsconfig: ${absolutePath}`);
|
|
51
|
+
}
|
|
52
|
+
const baseUrl = parsed.options.baseUrl ?? configDir;
|
|
53
|
+
const paths = new Map();
|
|
54
|
+
if (parsed.options.paths) {
|
|
55
|
+
for (const [alias, targets] of Object.entries(parsed.options.paths)) {
|
|
56
|
+
const resolvedTargets = targets.map((target) => (0, path_1.join)(baseUrl, target));
|
|
57
|
+
paths.set(alias, resolvedTargets);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { baseUrl, paths };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.TsconfigLoader = TsconfigLoader;
|
|
64
|
+
//# sourceMappingURL=tsconfig-loader.js.map
|
|
@@ -0,0 +1 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,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ;AAzCD,wCAyCC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hexaijs/plugin-contracts-generator",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "Collect domain events and commands from bounded contexts and generate frontend-compatible contracts package",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Sangwoo Hyun <wkdny.hyun@gmail.com>",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Seungcheol Baek <victoryiron.baek@gmail.com>",
|
|
12
|
+
"Donghyun Lee <edonghyun@naver.com>"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/workingdanny911/hexai.git",
|
|
17
|
+
"directory": "packages/plugin-contracts-generator"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/workingdanny911/hexai#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/workingdanny911/hexai/issues"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"hexai",
|
|
25
|
+
"hexagonal",
|
|
26
|
+
"clean-architecture",
|
|
27
|
+
"ddd",
|
|
28
|
+
"contracts",
|
|
29
|
+
"code-generation",
|
|
30
|
+
"typescript"
|
|
31
|
+
],
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"main": "dist/index.js",
|
|
37
|
+
"types": "dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"require": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./decorators": {
|
|
45
|
+
"types": "./dist/decorators/index.d.ts",
|
|
46
|
+
"import": "./dist/decorators/index.js",
|
|
47
|
+
"require": "./dist/decorators/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./runtime": {
|
|
50
|
+
"types": "./dist/runtime/index.d.ts",
|
|
51
|
+
"import": "./dist/runtime/index.js",
|
|
52
|
+
"require": "./dist/runtime/index.js"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"bin": {
|
|
56
|
+
"generate-contracts": "dist/cli.js"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"glob": "^10.3.0",
|
|
60
|
+
"minimatch": "^9.0.0",
|
|
61
|
+
"reflect-metadata": "^0.2.2"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"typescript": "^5.0.0",
|
|
65
|
+
"@hexaijs/cli": "^0.1.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^20.11.0",
|
|
69
|
+
"typescript": "^5.3.0",
|
|
70
|
+
"@hexaijs/core": "^0.2.0",
|
|
71
|
+
"@hexaijs/cli": "^0.1.0"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"clean": "rm -rf dist",
|
|
75
|
+
"build": "pnpm clean && tsc -p ./tsconfig.build.json",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:watch": "vitest"
|
|
78
|
+
}
|
|
79
|
+
}
|