-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2020 from undb-io/release/v1.0.0-69
Release version v1.0.0-69
- Loading branch information
Showing
26 changed files
with
206 additions
and
37 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
23 changes: 23 additions & 0 deletions
23
packages/command-handlers/src/handlers/submit-form.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,23 @@ | ||
import { SubmitFormCommand } from "@undb/commands" | ||
import { commandHandler } from "@undb/cqrs" | ||
import { singleton } from "@undb/di" | ||
import type { ICommandHandler } from "@undb/domain" | ||
import { createLogger } from "@undb/logger" | ||
import { injectRecordsService, type IRecordsService } from "@undb/table" | ||
|
||
@commandHandler(SubmitFormCommand) | ||
@singleton() | ||
export class SubmitFormCommandHandler implements ICommandHandler<SubmitFormCommand, any> { | ||
logger = createLogger(SubmitFormCommandHandler.name) | ||
constructor( | ||
@injectRecordsService() | ||
private readonly service: IRecordsService, | ||
) {} | ||
|
||
async execute(command: SubmitFormCommand): Promise<any> { | ||
this.logger.debug(command, "executing submit form command") | ||
const record = await this.service.submitForm(command, { formId: command.formId, values: command.values }) | ||
|
||
return record.id.value | ||
} | ||
} |
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,25 @@ | ||
import { Command, type CommandProps } from "@undb/domain" | ||
import type { IRecordValues } from "@undb/table" | ||
import { submitFormDTO, uniqueTableDTO } from "@undb/table" | ||
import { z } from "@undb/zod" | ||
|
||
export const submitFormCommand = submitFormDTO.merge(uniqueTableDTO) | ||
|
||
export type ISubmitFormCommand = z.infer<typeof submitFormCommand> | ||
|
||
export class SubmitFormCommand extends Command implements ISubmitFormCommand { | ||
public readonly tableId?: string | ||
public readonly formId: string | ||
public readonly baseName?: string | ||
public readonly tableName?: string | ||
public readonly values: IRecordValues | ||
|
||
constructor(props: CommandProps<ISubmitFormCommand>) { | ||
super(props) | ||
this.tableId = props.tableId | ||
this.formId = props.formId | ||
this.baseName = props.baseName | ||
this.tableName = props.tableName | ||
this.values = props.values | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
packages/table/src/modules/records/record/dto/submit-form.dto.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,12 @@ | ||
import { z } from "@undb/zod" | ||
import { formId } from "../../../forms/form/form-id.vo" | ||
import { recordId } from "../record-id.vo" | ||
import { recordValues } from "../record-values.vo" | ||
|
||
export const submitFormDTO = z.object({ | ||
id: recordId.optional(), | ||
formId: formId, | ||
values: recordValues, | ||
}) | ||
|
||
export type ISubmitFormDTO = z.infer<typeof submitFormDTO> |
19 changes: 19 additions & 0 deletions
19
packages/table/src/modules/records/services/methods/submit-form.method.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,19 @@ | ||
import { Some } from "@undb/domain" | ||
import type { IUniqueTableDTO } from "../../../../dto" | ||
import { withUniqueTable } from "../../../../specifications" | ||
import { RecordDO, type ISubmitFormDTO } from "../../record" | ||
import type { RecordsService } from "../records.service" | ||
|
||
export async function submitFormMethod( | ||
this: RecordsService, | ||
t: IUniqueTableDTO, | ||
dto: ISubmitFormDTO, | ||
): Promise<RecordDO> { | ||
const spec = withUniqueTable(t).unwrap() | ||
const table = (await this.tableRepository.findOne(Some(spec))).expect("Table not found") | ||
|
||
const record = RecordDO.create(table, dto) | ||
await this.repo.insert(table, record) | ||
|
||
return record | ||
} |
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
Oops, something went wrong.