diff --git a/src/Util/Feature/Meta/CommonFeatureMeta.ts b/src/Util/Feature/Meta/CommonFeatureMeta.ts index 77529ad..9b12731 100644 --- a/src/Util/Feature/Meta/CommonFeatureMeta.ts +++ b/src/Util/Feature/Meta/CommonFeatureMeta.ts @@ -1,4 +1,4 @@ -import type { JsonSerialize } from "@hexancore/common"; +import type { JsonSerialize, HFeatureBackendLayer } from "@hexancore/common"; export interface FeatureClassMeta { name: string; @@ -10,7 +10,7 @@ export interface FeatureClassMeta { filePath: string; } -export enum HObjectType { +export enum HObjectKind { Command = 'Command', Query = 'Query', Event = 'Event', @@ -24,18 +24,21 @@ export interface FeatureHObjectMeta extends FeatureClassMeta, JsonSerialize { context: string; className: string; get hashData(): string; - get objectType(): HObjectType; + get kind(): HObjectKind; + get layer(): HFeatureBackendLayer; } export type FeatureHObjectMap = Map; export class FeatureDtoMeta implements FeatureHObjectMeta { + public layer: HFeatureBackendLayer; + public constructor( public name: string, public context: string, public path: string, ) { - + this.layer = path.split('/')[0].toLowerCase() as HFeatureBackendLayer; } public static parse(plain: unknown): FeatureDtoMeta { @@ -51,8 +54,8 @@ export class FeatureDtoMeta implements FeatureHObjectMeta { return this.path + '.ts'; } - public get objectType(): HObjectType { - return HObjectType.Dto; + public get kind(): HObjectKind.Dto { + return HObjectKind.Dto; } public get hashData(): string { diff --git a/src/Util/Feature/Meta/FeatureApplicationMeta.ts b/src/Util/Feature/Meta/FeatureApplicationMeta.ts index a40104f..81f4d34 100644 --- a/src/Util/Feature/Meta/FeatureApplicationMeta.ts +++ b/src/Util/Feature/Meta/FeatureApplicationMeta.ts @@ -1,5 +1,5 @@ -import { type JsonSerialize, LogicError } from "@hexancore/common"; -import { FeatureClassMeta, FeatureDtoMeta, FeatureHObjectMap, FeatureHObjectMeta, HObjectType } from "./CommonFeatureMeta"; +import { type JsonSerialize, LogicError, HFeatureBackendLayer } from "@hexancore/common"; +import { FeatureClassMeta, FeatureDtoMeta, FeatureHObjectMap, FeatureHObjectMeta, HObjectKind } from "./CommonFeatureMeta"; export interface FeatureApplicationMessageMeta extends FeatureHObjectMeta { handlerClass: string; @@ -28,14 +28,20 @@ export class FeatureApplicationCommandMeta implements FeatureApplicationMessageM return this.path + '/' + this.className + '.ts'; } - public get objectType(): HObjectType.Command { - return HObjectType.Command; + public get kind(): HObjectKind.Command { + return HObjectKind.Command; + } + + public get layer(): HFeatureBackendLayer { + return 'application'; } public get hashData(): string { return this.path; } + + public toJSON(): any { return { name: this.name, @@ -67,8 +73,12 @@ export class FeatureApplicationQueryMeta implements FeatureApplicationMessageMet return this.path + '/' + this.className + '.ts'; } - public get objectType(): HObjectType.Query { - return HObjectType.Query; + public get kind(): HObjectKind.Query { + return HObjectKind.Query; + } + + public get layer(): HFeatureBackendLayer { + return 'application'; } public get hashData(): string { diff --git a/src/Util/Feature/Meta/FeatureDomainMeta.ts b/src/Util/Feature/Meta/FeatureDomainMeta.ts index 8c94f28..1671e17 100644 --- a/src/Util/Feature/Meta/FeatureDomainMeta.ts +++ b/src/Util/Feature/Meta/FeatureDomainMeta.ts @@ -1,5 +1,5 @@ -import { LogicError } from "@hexancore/common"; -import { FeatureHObjectMeta, HObjectType, type FeatureHObjectMap } from "./CommonFeatureMeta"; +import { LogicError, HFeatureBackendLayer } from "@hexancore/common"; +import { FeatureHObjectMeta, HObjectKind, type FeatureHObjectMap} from "./CommonFeatureMeta"; export class FeatureAggregateRootMeta implements FeatureHObjectMeta { public repositoryName: string; @@ -38,8 +38,12 @@ export class FeatureAggregateRootMeta implements FeatureHObjectMeta { return this.name; } - public get objectType(): HObjectType { - return HObjectType.AggregateRoot; + public get kind(): HObjectKind.AggregateRoot { + return HObjectKind.AggregateRoot; + } + + public get layer(): HFeatureBackendLayer { + return 'domain'; } public get hashData(): string { @@ -88,8 +92,12 @@ export class FeatureEntityMeta implements FeatureHObjectMeta { return this.aggregateRootName; } - public get objectType(): HObjectType { - return HObjectType.Entity; + public get kind(): HObjectKind.Entity { + return HObjectKind.Entity; + } + + public get layer(): HFeatureBackendLayer { + return 'domain'; } public get hashData(): string { @@ -133,14 +141,18 @@ export class FeatureValueObjectMeta implements FeatureHObjectMeta { return this.name; } - public get objectType(): HObjectType.ValueObject { - return HObjectType.ValueObject; + public get kind(): HObjectKind.ValueObject { + return HObjectKind.ValueObject; } public get hashData(): string { return this.path; } + public get layer(): HFeatureBackendLayer { + return 'domain'; + } + public toJSON(): any { return { name: this.name, @@ -164,7 +176,7 @@ export class FeatureDomainMeta { const data = plain as Record; const aggregateRoots = data.aggregateRoots.map(FeatureAggregateRootMeta.parse); const valueObjects = data.valueObjects.map(FeatureValueObjectMeta.parse); - return new FeatureDomainMeta (aggregateRoots, valueObjects); + return new FeatureDomainMeta(aggregateRoots, valueObjects); } public collectHObjects(map: FeatureHObjectMap): void { diff --git a/test/integration/Compiler/Transformer/FeatureTsTransformer.test.ts b/test/integration/Compiler/Transformer/FeatureTsTransformer.test.ts index 3b539e6..8d9769c 100644 --- a/test/integration/Compiler/Transformer/FeatureTsTransformer.test.ts +++ b/test/integration/Compiler/Transformer/FeatureTsTransformer.test.ts @@ -33,15 +33,6 @@ describe(FeatureModuleTsTransformer.constructor.name, () => { expect(out.outputText).toMatchSnapshot(); }); - - test.skip("transform HObject: Command", () => { - const sourceFilePath = process.cwd() + "/test/helper/libs/test-lib/src/Book/Application/Book/Command/Create/BookCreateCommand.ts"; - - const out = helper.transpileModule(transformer.transform.bind(transformer), sourceFilePath); - - expect(out.outputText).toMatchSnapshot(); - }); - }); diff --git a/test/integration/Compiler/Transformer/__snapshots__/FeatureTsTransformer.test.ts.snap b/test/integration/Compiler/Transformer/__snapshots__/FeatureTsTransformer.test.ts.snap index 4c6bf19..3d0deaf 100644 --- a/test/integration/Compiler/Transformer/__snapshots__/FeatureTsTransformer.test.ts.snap +++ b/test/integration/Compiler/Transformer/__snapshots__/FeatureTsTransformer.test.ts.snap @@ -24,16 +24,3 @@ exports.BookModule = BookModule = tslib_1.__decorate([ ], BookModule); //# sourceMappingURL=BookModule.js.map" `; - -exports[`Function transform HObject: Command 1`] = ` -""use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BookCreateCommand = void 0; -class BookCreateCommand { - constructor(title) { - this.title = title; - } -} -exports.BookCreateCommand = BookCreateCommand; -//# sourceMappingURL=BookCreateCommand.js.map" -`; diff --git a/test/unit/Util/Feature/__snapshots__/FeatureModuleDiscoverer.test.ts.snap b/test/unit/Util/Feature/__snapshots__/FeatureModuleDiscoverer.test.ts.snap index fa9ae62..f8a4f04 100644 --- a/test/unit/Util/Feature/__snapshots__/FeatureModuleDiscoverer.test.ts.snap +++ b/test/unit/Util/Feature/__snapshots__/FeatureModuleDiscoverer.test.ts.snap @@ -68,10 +68,12 @@ exports[`Function hObjectMap 1`] = ` name: BookDto context: Book path: Application/Book/Dto/BookDto + layer: application Application/Book/Dto/TestTransformDto.ts: name: TestTransformDto context: Book path: Application/Book/Dto/TestTransformDto + layer: application Domain/Book/Shared/ValueObject/BookCopyId.ts: name: BookCopyId context: Book