-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): create option command & handler
- Loading branch information
Showing
10 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
apps/backend/src/modules/table/commands/create-option.command.handler.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CreateOptionCommand, CreateOptionCommandHandler as DomainHandler, type ITableRepository } from '@egodb/core' | ||
import type { ICommandHandler } from '@nestjs/cqrs' | ||
import { CommandHandler } from '@nestjs/cqrs' | ||
import { InjectTableReposiory } from '../adapters' | ||
|
||
@CommandHandler(CreateOptionCommand) | ||
export class CreateOptionCommandHandler extends DomainHandler implements ICommandHandler<CreateOptionCommand> { | ||
constructor( | ||
@InjectTableReposiory() | ||
protected readonly repo: ITableRepository, | ||
) { | ||
super(repo) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Button, IconPlus } from '@egodb/ui' | ||
|
||
export const NewStackLane: React.FC = () => { | ||
return ( | ||
<Button w={300} variant="white" leftIcon={<IconPlus />}> | ||
New Stack | ||
</Button> | ||
) | ||
} |
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
15 changes: 15 additions & 0 deletions
15
packages/core/commands/create-option/create-option.command.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { CommandProps } from '@egodb/domain' | ||
import { Command } from '@egodb/domain' | ||
import type { ICreateOptionSchema } from '../../option' | ||
import type { ICreateOptionCommandInput } from './create-table.command.interface' | ||
|
||
export class CreateOptionCommand extends Command implements ICreateOptionCommandInput { | ||
readonly tableId: string | ||
readonly option: ICreateOptionSchema | ||
|
||
constructor(props: CommandProps<ICreateOptionCommandInput>) { | ||
super(props) | ||
this.tableId = props.tableId | ||
this.option = props.option | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/core/commands/create-option/create-table.command.handler.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { type ICommandHandler } from '@egodb/domain' | ||
import type { ITableRepository } from '../../table.repository' | ||
import type { CreateOptionCommand } from './create-option.command' | ||
|
||
type ICreateOptionCommandHandler = ICommandHandler<CreateOptionCommand, void> | ||
|
||
export class CreateOptionCommandHandler implements ICreateOptionCommandHandler { | ||
constructor(protected readonly repo: ITableRepository) {} | ||
|
||
async execute(command: CreateOptionCommand): Promise<void> { | ||
const table = (await this.repo.findOneById(command.tableId)).unwrap() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/core/commands/create-option/create-table.command.input.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as z from 'zod' | ||
import { createOptionSchema } from '../../option' | ||
import { tableIdSchema } from '../../value-objects' | ||
|
||
export const createOptionCommandInput = z.object({ | ||
tableId: tableIdSchema, | ||
option: createOptionSchema, | ||
}) |
4 changes: 4 additions & 0 deletions
4
packages/core/commands/create-option/create-table.command.interface.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type * as z from 'zod' | ||
import type { createOptionCommandInput } from './create-table.command.input' | ||
|
||
export type ICreateOptionCommandInput = z.infer<typeof createOptionCommandInput> |
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,4 @@ | ||
export * from './create-option.command' | ||
export * from './create-table.command.handler' | ||
export * from './create-table.command.input' | ||
export * from './create-table.command.interface' |
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