-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
267 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import { | ||
AR, | ||
AnyHCommand, | ||
ExtractHCommandResultValueType, | ||
AnyHQuery, | ||
ExtractHQueryResultValueType, | ||
AnyHEvent | ||
type AR, | ||
type AnyHCommand, | ||
type HEvent, | ||
type AnyHQuery, | ||
type HCommandAsyncResultType, | ||
type HQueryAsyncResultType | ||
} from '@hexancore/common'; | ||
|
||
|
||
export type HCommandHandleResult<T extends AnyHCommand> = AR<ExtractHCommandResultValueType<T>>; | ||
export type HQueryHandleResult<T extends AnyHQuery> = AR<ExtractHQueryResultValueType<T>>; | ||
|
||
export abstract class GeneralBus { | ||
public abstract handleCommand<T extends AnyHCommand>(command: T): HCommandHandleResult<T>; | ||
public abstract handleEvent(event: AnyHEvent): AR<boolean>; | ||
public abstract handleQuery<T extends AnyHQuery>(query: T): HQueryHandleResult<T>; | ||
public abstract handleCommand<T extends AnyHCommand>(command: T): HCommandAsyncResultType<T>; | ||
public abstract handleEvent(event: HEvent): AR<boolean>; | ||
public abstract handleQuery<T extends AnyHQuery>(query: T): HQueryAsyncResultType<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ICommandHandler } from "@nestjs/cqrs"; | ||
import { type AnyHCommand, type HCommandResultType, type HCommandAsyncResultType, type HCommandAsyncResultPromiseType } from "@hexancore/common"; | ||
|
||
export abstract class HCommandHandler<T extends AnyHCommand> implements ICommandHandler<T, HCommandResultType<T>> { | ||
public execute(command: T): HCommandAsyncResultPromiseType<T> { | ||
return this.handle(command).p; | ||
} | ||
|
||
protected abstract handle(command: T): HCommandAsyncResultType<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { type IEventHandler } from "@nestjs/cqrs"; | ||
import { type HEvent, type AR } from "@hexancore/common"; | ||
|
||
export abstract class HEventHandler<T extends HEvent> implements IEventHandler<T> { | ||
public abstract handle(event: T): AR<unknown>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { type AnyHQuery, HQueryResultType, HQueryAsyncResultType } from "@hexancore/common"; | ||
import { type IQueryHandler } from "@nestjs/cqrs"; | ||
|
||
export abstract class HQueryHandler<T extends AnyHQuery> implements IQueryHandler<T, HQueryResultType<T>> { | ||
public execute(query: T): Promise<HQueryResultType<T>> { | ||
return this.handle(query).p; | ||
} | ||
|
||
protected abstract handle(query: T): HQueryAsyncResultType<T>; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/Compiler/Transformer/Feature/HObject/HObjectParseTsFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
test/helper/libs/test-lib/src/Book/Application/Book/Command/Create/BookCreateCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { HCommand } from "@hexancore/common"; | ||
import { BookDto } from "../../Dto/BookDto"; | ||
|
||
export class BookCreateCommand extends HCommand<BookCreateCommand, void> { | ||
export class BookCreateCommand extends HCommand<BookDto> { | ||
public title!: string; | ||
} | ||
|
||
} |
18 changes: 11 additions & 7 deletions
18
...helper/libs/test-lib/src/Book/Application/Book/Command/Create/BookCreateCommandHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { CommandHandler, type ICommandHandler } from "@nestjs/cqrs"; | ||
import { BookCreateCommand } from "./BookCreateCommand"; | ||
import { OKAP, type ARP } from "@hexancore/common"; | ||
import { HCommandHandler } from "@/Application/HCommandHandler"; | ||
import { OKA, ERRA, type HCommandAsyncResultType } from "@hexancore/common"; | ||
import { BookDto } from "../../Dto/BookDto"; | ||
import { BookCreateCommand } from "./BookCreateCommand"; | ||
import { CommandHandler } from "@nestjs/cqrs"; | ||
|
||
@CommandHandler(BookCreateCommand) | ||
export class BookCreateCommandHandler implements ICommandHandler<BookCreateCommand> { | ||
public execute(command: BookCreateCommand): ARP<BookDto> { | ||
return OKAP(BookDto.cs({ | ||
title: command.title, | ||
export class BookCreateCommandHandler extends HCommandHandler<BookCreateCommand> { | ||
protected handle(command: BookCreateCommand): HCommandAsyncResultType<BookCreateCommand> { | ||
if (command.title === "error") { | ||
return ERRA("error"); | ||
} | ||
|
||
return OKA(BookDto.cs({ | ||
title: command.title, | ||
})); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
test/helper/libs/test-lib/src/Book/Application/Book/Dto/ArrayItemsTestDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Dto, v } from '@hexancore/common'; | ||
|
||
export class ArrayItemsTestDto extends Dto<ArrayItemsTestDto> { | ||
export class ArrayItemsTestDto extends Dto { | ||
|
||
public arrayMinItemsField!: v.int[] & v.items.min<2>; | ||
public arrayMaxItemsField!: v.int[] & v.items.max<2>; | ||
public arrayExaclyItemsField!: v.int[] & v.items.exactly<2>; | ||
public arrayBetweenItemsField!: v.int[] & v.items.between<0, 2>; | ||
|
||
public optionalArrayItemsField?: v.int[] & v.items.min<2>; | ||
} |
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/BookDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Dto } from "@hexancore/common"; | ||
|
||
export class BookDto extends Dto<BookDto> { | ||
export class BookDto extends Dto { | ||
public title?: string; | ||
} |
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/FloatTestDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/IntTestDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/StringTestDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/TestTransformDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Dto/UIntTestDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/helper/libs/test-lib/src/Book/Application/Book/Query/GetById/BookGetByIdQuery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { HQuery } from "@hexancore/common"; | ||
import type { BookDto } from "../../Dto/BookDto"; | ||
|
||
export class BookGetByIdQuery extends HQuery<BookGetByIdQuery, BookDto> { | ||
export class BookGetByIdQuery extends HQuery<BookDto> { | ||
public title!: string; | ||
} |
Oops, something went wrong.