From 703be8d22218871ec09c6cf3328ae1d86b3654dd Mon Sep 17 00:00:00 2001 From: Lambdius Date: Fri, 16 Oct 2026 10:44:52 +0200 Subject: [PATCH] feat: add HR HTTP controllers and DTOs --- package.json | 2 +- pnpm-lock.yaml | 12 +- pnpm-workspace.yaml | 2 +- .../controllers/employee.controller.ts | 215 ++++++++++++++++++ .../hr-approval-step.controller.ts | 154 +++++++++++++ .../controllers/hr-request.controller.ts | 152 +++++++++++++ src/context/interface/controllers/index.ts | 20 +- .../controllers/leave-policy.controller.ts | 173 ++++++++++++++ .../controllers/position.controller.ts | 173 ++++++++++++++ .../work-calendar-exception.controller.ts | 139 +++++++++++ .../controllers/work-calendar.controller.ts | 173 ++++++++++++++ .../controllers/work-schedule.controller.ts | 173 ++++++++++++++ src/context/interface/dto/.gitkeep | 0 src/context/interface/dto/employee/index.ts | 15 ++ .../interface/dto/employee/req/archive.dto.ts | 30 +++ .../interface/dto/employee/req/create.dto.ts | 47 ++++ .../dto/employee/req/get-by-id.dto.ts | 23 ++ .../dto/employee/req/get-list.dto.ts | 46 ++++ .../dto/employee/req/link-account.dto.ts | 35 +++ .../interface/dto/employee/req/restore.dto.ts | 30 +++ .../dto/employee/req/set-hrbp.dto.ts | 36 +++ .../dto/employee/req/unlink-account.dto.ts | 30 +++ .../interface/dto/employee/req/update.dto.ts | 35 +++ .../interface/dto/employee/res/entity.dto.ts | 114 ++++++++++ .../interface/dto/employee/res/list.dto.ts | 47 ++++ .../dto/employee/utils/filters.dto.ts | 176 ++++++++++++++ .../interface/dto/employee/utils/sort.dto.ts | 62 +++++ .../interface/dto/hr-approval-step/index.ts | 12 + .../dto/hr-approval-step/req/approve.dto.ts | 41 ++++ .../dto/hr-approval-step/req/get-by-id.dto.ts | 23 ++ .../dto/hr-approval-step/req/get-list.dto.ts | 46 ++++ .../dto/hr-approval-step/req/reassign.dto.ts | 35 +++ .../dto/hr-approval-step/req/reject.dto.ts | 41 ++++ .../req/return-for-revision.dto.ts | 41 ++++ .../dto/hr-approval-step/res/entity.dto.ts | 61 +++++ .../dto/hr-approval-step/res/list.dto.ts | 47 ++++ .../dto/hr-approval-step/utils/filters.dto.ts | 106 +++++++++ .../dto/hr-approval-step/utils/sort.dto.ts | 50 ++++ src/context/interface/dto/hr-request/index.ts | 12 + .../dto/hr-request/req/create.dto.ts | 70 ++++++ .../dto/hr-request/req/get-by-id.dto.ts | 23 ++ .../dto/hr-request/req/get-list.dto.ts | 46 ++++ .../dto/hr-request/req/submit.dto.ts | 60 +++++ .../dto/hr-request/req/update.dto.ts | 39 ++++ .../dto/hr-request/req/withdraw.dto.ts | 30 +++ .../dto/hr-request/res/entity.dto.ts | 129 +++++++++++ .../interface/dto/hr-request/res/list.dto.ts | 47 ++++ .../dto/hr-request/utils/filters.dto.ts | 183 +++++++++++++++ .../dto/hr-request/utils/sort.dto.ts | 80 +++++++ .../interface/dto/leave-policy/index.ts | 13 ++ .../dto/leave-policy/req/archive.dto.ts | 30 +++ .../dto/leave-policy/req/create.dto.ts | 40 ++++ .../dto/leave-policy/req/get-by-id.dto.ts | 23 ++ .../dto/leave-policy/req/get-list.dto.ts | 46 ++++ .../dto/leave-policy/req/purge.dto.ts | 30 +++ .../dto/leave-policy/req/restore.dto.ts | 30 +++ .../dto/leave-policy/req/revision.dto.ts | 43 ++++ .../dto/leave-policy/res/entity.dto.ts | 59 +++++ .../dto/leave-policy/res/list.dto.ts | 47 ++++ .../dto/leave-policy/utils/filters.dto.ts | 78 +++++++ .../dto/leave-policy/utils/sort.dto.ts | 32 +++ src/context/interface/dto/position/index.ts | 13 ++ .../interface/dto/position/req/archive.dto.ts | 30 +++ .../interface/dto/position/req/create.dto.ts | 82 +++++++ .../dto/position/req/get-by-id.dto.ts | 23 ++ .../dto/position/req/get-list.dto.ts | 46 ++++ .../interface/dto/position/req/purge.dto.ts | 30 +++ .../interface/dto/position/req/restore.dto.ts | 30 +++ .../interface/dto/position/req/update.dto.ts | 35 +++ .../interface/dto/position/res/entity.dto.ts | 107 +++++++++ .../interface/dto/position/res/list.dto.ts | 47 ++++ .../dto/position/utils/filters.dto.ts | 127 +++++++++++ .../interface/dto/position/utils/sort.dto.ts | 38 ++++ .../dto/work-calendar-exception/index.ts | 11 + .../work-calendar-exception/req/create.dto.ts | 61 +++++ .../req/get-by-id.dto.ts | 23 ++ .../req/get-list.dto.ts | 46 ++++ .../work-calendar-exception/req/purge.dto.ts | 30 +++ .../work-calendar-exception/req/update.dto.ts | 35 +++ .../work-calendar-exception/res/entity.dto.ts | 64 ++++++ .../work-calendar-exception/res/list.dto.ts | 47 ++++ .../utils/filters.dto.ts | 91 ++++++++ .../work-calendar-exception/utils/sort.dto.ts | 38 ++++ .../interface/dto/work-calendar/index.ts | 13 ++ .../dto/work-calendar/req/archive.dto.ts | 30 +++ .../dto/work-calendar/req/create.dto.ts | 52 +++++ .../dto/work-calendar/req/get-by-id.dto.ts | 23 ++ .../dto/work-calendar/req/get-list.dto.ts | 46 ++++ .../dto/work-calendar/req/purge.dto.ts | 30 +++ .../dto/work-calendar/req/restore.dto.ts | 30 +++ .../dto/work-calendar/req/update.dto.ts | 35 +++ .../dto/work-calendar/res/entity.dto.ts | 66 ++++++ .../dto/work-calendar/res/list.dto.ts | 47 ++++ .../dto/work-calendar/utils/filters.dto.ts | 85 +++++++ .../dto/work-calendar/utils/sort.dto.ts | 32 +++ .../interface/dto/work-schedule/index.ts | 13 ++ .../dto/work-schedule/req/archive.dto.ts | 30 +++ .../dto/work-schedule/req/create.dto.ts | 46 ++++ .../dto/work-schedule/req/get-by-id.dto.ts | 23 ++ .../dto/work-schedule/req/get-list.dto.ts | 46 ++++ .../dto/work-schedule/req/purge.dto.ts | 30 +++ .../dto/work-schedule/req/restore.dto.ts | 30 +++ .../dto/work-schedule/req/revision.dto.ts | 50 ++++ .../dto/work-schedule/res/entity.dto.ts | 64 ++++++ .../dto/work-schedule/res/list.dto.ts | 47 ++++ .../dto/work-schedule/utils/filters.dto.ts | 85 +++++++ .../dto/work-schedule/utils/sort.dto.ts | 32 +++ 107 files changed, 5837 insertions(+), 9 deletions(-) create mode 100644 src/context/interface/controllers/employee.controller.ts create mode 100644 src/context/interface/controllers/hr-approval-step.controller.ts create mode 100644 src/context/interface/controllers/hr-request.controller.ts create mode 100644 src/context/interface/controllers/leave-policy.controller.ts create mode 100644 src/context/interface/controllers/position.controller.ts create mode 100644 src/context/interface/controllers/work-calendar-exception.controller.ts create mode 100644 src/context/interface/controllers/work-calendar.controller.ts create mode 100644 src/context/interface/controllers/work-schedule.controller.ts delete mode 100644 src/context/interface/dto/.gitkeep create mode 100644 src/context/interface/dto/employee/index.ts create mode 100644 src/context/interface/dto/employee/req/archive.dto.ts create mode 100644 src/context/interface/dto/employee/req/create.dto.ts create mode 100644 src/context/interface/dto/employee/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/employee/req/get-list.dto.ts create mode 100644 src/context/interface/dto/employee/req/link-account.dto.ts create mode 100644 src/context/interface/dto/employee/req/restore.dto.ts create mode 100644 src/context/interface/dto/employee/req/set-hrbp.dto.ts create mode 100644 src/context/interface/dto/employee/req/unlink-account.dto.ts create mode 100644 src/context/interface/dto/employee/req/update.dto.ts create mode 100644 src/context/interface/dto/employee/res/entity.dto.ts create mode 100644 src/context/interface/dto/employee/res/list.dto.ts create mode 100644 src/context/interface/dto/employee/utils/filters.dto.ts create mode 100644 src/context/interface/dto/employee/utils/sort.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/index.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/approve.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/get-list.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/reassign.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/reject.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/req/return-for-revision.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/res/entity.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/res/list.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/utils/filters.dto.ts create mode 100644 src/context/interface/dto/hr-approval-step/utils/sort.dto.ts create mode 100644 src/context/interface/dto/hr-request/index.ts create mode 100644 src/context/interface/dto/hr-request/req/create.dto.ts create mode 100644 src/context/interface/dto/hr-request/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/hr-request/req/get-list.dto.ts create mode 100644 src/context/interface/dto/hr-request/req/submit.dto.ts create mode 100644 src/context/interface/dto/hr-request/req/update.dto.ts create mode 100644 src/context/interface/dto/hr-request/req/withdraw.dto.ts create mode 100644 src/context/interface/dto/hr-request/res/entity.dto.ts create mode 100644 src/context/interface/dto/hr-request/res/list.dto.ts create mode 100644 src/context/interface/dto/hr-request/utils/filters.dto.ts create mode 100644 src/context/interface/dto/hr-request/utils/sort.dto.ts create mode 100644 src/context/interface/dto/leave-policy/index.ts create mode 100644 src/context/interface/dto/leave-policy/req/archive.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/create.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/get-list.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/purge.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/restore.dto.ts create mode 100644 src/context/interface/dto/leave-policy/req/revision.dto.ts create mode 100644 src/context/interface/dto/leave-policy/res/entity.dto.ts create mode 100644 src/context/interface/dto/leave-policy/res/list.dto.ts create mode 100644 src/context/interface/dto/leave-policy/utils/filters.dto.ts create mode 100644 src/context/interface/dto/leave-policy/utils/sort.dto.ts create mode 100644 src/context/interface/dto/position/index.ts create mode 100644 src/context/interface/dto/position/req/archive.dto.ts create mode 100644 src/context/interface/dto/position/req/create.dto.ts create mode 100644 src/context/interface/dto/position/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/position/req/get-list.dto.ts create mode 100644 src/context/interface/dto/position/req/purge.dto.ts create mode 100644 src/context/interface/dto/position/req/restore.dto.ts create mode 100644 src/context/interface/dto/position/req/update.dto.ts create mode 100644 src/context/interface/dto/position/res/entity.dto.ts create mode 100644 src/context/interface/dto/position/res/list.dto.ts create mode 100644 src/context/interface/dto/position/utils/filters.dto.ts create mode 100644 src/context/interface/dto/position/utils/sort.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/index.ts create mode 100644 src/context/interface/dto/work-calendar-exception/req/create.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/req/get-list.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/req/purge.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/req/update.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/res/entity.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/res/list.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/utils/filters.dto.ts create mode 100644 src/context/interface/dto/work-calendar-exception/utils/sort.dto.ts create mode 100644 src/context/interface/dto/work-calendar/index.ts create mode 100644 src/context/interface/dto/work-calendar/req/archive.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/create.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/get-list.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/purge.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/restore.dto.ts create mode 100644 src/context/interface/dto/work-calendar/req/update.dto.ts create mode 100644 src/context/interface/dto/work-calendar/res/entity.dto.ts create mode 100644 src/context/interface/dto/work-calendar/res/list.dto.ts create mode 100644 src/context/interface/dto/work-calendar/utils/filters.dto.ts create mode 100644 src/context/interface/dto/work-calendar/utils/sort.dto.ts create mode 100644 src/context/interface/dto/work-schedule/index.ts create mode 100644 src/context/interface/dto/work-schedule/req/archive.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/create.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/get-by-id.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/get-list.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/purge.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/restore.dto.ts create mode 100644 src/context/interface/dto/work-schedule/req/revision.dto.ts create mode 100644 src/context/interface/dto/work-schedule/res/entity.dto.ts create mode 100644 src/context/interface/dto/work-schedule/res/list.dto.ts create mode 100644 src/context/interface/dto/work-schedule/utils/filters.dto.ts create mode 100644 src/context/interface/dto/work-schedule/utils/sort.dto.ts diff --git a/package.json b/package.json index 3dc931b..62fceb9 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@mikro-orm/core": "7.1.13", "@mikro-orm/nestjs": "7.0.2", "@mikro-orm/postgresql": "7.1.13", - "@monadiam/shared": "github:MonadIAM/shared#v2.0.18", + "@monadiam/shared": "github:MonadIAM/shared#v2.0.19", "@nest-lab/throttler-storage-redis": "1.2.0", "@nestjs/bullmq": "11.0.5", "@nestjs/common": "11.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d6594a..076e2a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,8 +39,8 @@ importers: specifier: 7.1.13 version: 7.1.13(@mikro-orm/core@7.1.13) '@monadiam/shared': - specifier: github:MonadIAM/shared#v2.0.18 - version: https://codeload.github.com/MonadIAM/shared/tar.gz/87c7b77806041337becc7027619cf0372cb4d8af + specifier: github:MonadIAM/shared#v2.0.19 + version: https://codeload.github.com/MonadIAM/shared/tar.gz/43cbacc8643c96b50e23c9f045dc0cf26cd374d0 '@nest-lab/throttler-storage-redis': specifier: 1.2.0 version: 1.2.0(@nestjs/common@11.2.1(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(@nestjs/core@11.2.1)(@nestjs/throttler@6.5.0(@nestjs/common@11.2.1(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(@nestjs/core@11.2.1)(reflect-metadata@0.2.2))(ioredis@6.0.0(supports-color@8.1.1))(reflect-metadata@0.2.2) @@ -1106,9 +1106,9 @@ packages: engines: {node: '>=22.0.0'} hasBin: true - '@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/87c7b77806041337becc7027619cf0372cb4d8af': - resolution: {gitHosted: true, tarball: https://codeload.github.com/MonadIAM/shared/tar.gz/87c7b77806041337becc7027619cf0372cb4d8af} - version: 2.0.18 + '@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/43cbacc8643c96b50e23c9f045dc0cf26cd374d0': + resolution: {gitHosted: true, integrity: sha512-9d/pRa2pwYgusctltykmDWCuxxG1VAu6sNqTBHaDHN5fO40ebAAw1aIPfffo/dGAQcReqeW/lAXcM5AXn6LAtg==, tarball: https://codeload.github.com/MonadIAM/shared/tar.gz/43cbacc8643c96b50e23c9f045dc0cf26cd374d0} + version: 2.0.19 engines: {node: 24.18.0} '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.4': @@ -6088,7 +6088,7 @@ snapshots: uuid: 11.1.1 zod: 3.25.76 - '@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/87c7b77806041337becc7027619cf0372cb4d8af': {} + '@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/43cbacc8643c96b50e23c9f045dc0cf26cd374d0': {} '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.4': optional: true diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 9ba9e4b..fd17242 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -6,7 +6,7 @@ color: true loglevel: info savePrefix: "" allowBuilds: - "@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/87c7b77806041337becc7027619cf0372cb4d8af": true + "@monadiam/shared@https://codeload.github.com/MonadIAM/shared/tar.gz/43cbacc8643c96b50e23c9f045dc0cf26cd374d0": true "@launchql/protobufjs": true "msgpackr-extract": true "unrs-resolver": true diff --git a/src/context/interface/controllers/employee.controller.ts b/src/context/interface/controllers/employee.controller.ts new file mode 100644 index 0000000..da669f6 --- /dev/null +++ b/src/context/interface/controllers/employee.controller.ts @@ -0,0 +1,215 @@ +import { Controller, HttpStatus, HttpCode, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { EMPLOYEE_COMMANDS } from "~context/application/commands"; +import { EMPLOYEE_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + UnlinkAccountQueryDTO, + UnlinkAccountBodyDTO, + LinkAccountQueryDTO, + LinkAccountBodyDTO, + ArchiveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + RestoreQueryDTO, + SetHRBPQueryDTO, + ArchiveBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + RestoreBodyDTO, + SetHrbpBodyDTO, + UpdateQueryDTO, + CreateBodyDTO, + UpdateBodyDTO, + EmployeeDTO, + ListDTO, +} from "../dto/employee"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("Employee") +@Controller("/employee") +export class EmployeeController { + public constructor( + @Inject(EMPLOYEE_COMMANDS) + private readonly employeeCommands: Commands.Employee.ControllerContract, + @Inject(EMPLOYEE_QUERIES) + private readonly employeeQueries: Queries.Employee.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(EmployeeDTO) + @ApiResponse({ status: OK, type: EmployeeDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_READ_ABSOLUTE, PermissionCode.EMPLOYEE_READ_COMMON) + @ApiOperation({ + summary: "Returns an employee by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.Employee.FindUnique.Result { + return this.employeeQueries.findUnique({ organization, realm, view, employee: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_READ_ABSOLUTE, PermissionCode.EMPLOYEE_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of employees", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.Employee.FindMany.Result { + return this.employeeQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_CREATE) + @ApiOperation({ + summary: "Creates a new employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.Create.Result { + return this.employeeCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Patch("update") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_UPDATE) + @ApiOperation({ + summary: "Updates employee metadata", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public update( + @Query() { id, organization, realm }: UpdateQueryDTO, + @Body() input: UpdateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.Update.Result { + return this.employeeCommands.update({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("link-account") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_LINK_ACCOUNT) + @ApiOperation({ + summary: "Links an account to an employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public linkAccount( + @Query() { id, organization, realm }: LinkAccountQueryDTO, + @Body() input: LinkAccountBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.LinkAccount.Result { + return this.employeeCommands.linkAccount({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("unlink-account") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_LINK_ACCOUNT) + @ApiOperation({ + summary: "Unlinks an account from an employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public unlinkAccount( + @Query() { id, organization, realm }: UnlinkAccountQueryDTO, + @Body() input: UnlinkAccountBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.UnlinkAccount.Result { + return this.employeeCommands.unlinkAccount({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("archive") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_ARCHIVE) + @ApiOperation({ + summary: "Archives an employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public archive( + @Query() { id, organization, realm }: ArchiveQueryDTO, + @Body() input: ArchiveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.Archive.Result { + return this.employeeCommands.archive({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("restore") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_RESTORE) + @ApiOperation({ + summary: "Restores an employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public restore( + @Query() { id, organization, realm }: RestoreQueryDTO, + @Body() input: RestoreBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.Restore.Result { + return this.employeeCommands.restore({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("set-hrbp") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.EMPLOYEE_SET_HRBP) + @ApiOperation({ + summary: "Sets the HRBP for an employee", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public setHRBP( + @Query() { id, organization, realm }: SetHRBPQueryDTO, + @Body() input: SetHrbpBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Employee.SetHRBP.Result { + return this.employeeCommands.setHRBP({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/hr-approval-step.controller.ts b/src/context/interface/controllers/hr-approval-step.controller.ts new file mode 100644 index 0000000..bbcae73 --- /dev/null +++ b/src/context/interface/controllers/hr-approval-step.controller.ts @@ -0,0 +1,154 @@ +import { Controller, HttpStatus, HttpCode, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { HR_APPROVAL_STEP_COMMANDS } from "~context/application/commands"; +import { HR_APPROVAL_STEP_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + ReturnForRevisionQueryDTO, + ReturnForRevisionBodyDTO, + HRApprovalStepDTO, + ReassignQueryDTO, + ApproveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + ReassignBodyDTO, + ApproveBodyDTO, + GetListBodyDTO, + RejectQueryDTO, + RejectBodyDTO, + ListDTO, +} from "../dto/hr-approval-step"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, OK } = HttpStatus; + +@ApiTags("HRApprovalStep") +@Controller("/hr-approval-step") +export class HRApprovalStepController { + public constructor( + @Inject(HR_APPROVAL_STEP_COMMANDS) + private readonly hrApprovalStepCommands: Commands.HRApprovalStep.ControllerContract, + @Inject(HR_APPROVAL_STEP_QUERIES) + private readonly hrApprovalStepQueries: Queries.HRApprovalStep.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(HRApprovalStepDTO) + @ApiResponse({ status: OK, type: HRApprovalStepDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_READ_ABSOLUTE, PermissionCode.HR_APPROVAL_STEP_READ_COMMON) + @ApiOperation({ + summary: "Returns an HR approval step by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique( + @Query() { organization, realm, view, id }: GetByIdQueryDTO, + ): Queries.HRApprovalStep.FindUnique.Result { + return this.hrApprovalStepQueries.findUnique({ organization, realm, view, step: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_READ_ABSOLUTE, PermissionCode.HR_APPROVAL_STEP_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of HR approval steps", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.HRApprovalStep.FindMany.Result { + return this.hrApprovalStepQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @HttpCode(OK) + @Patch("reassign") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_REASSIGN) + @ApiOperation({ + summary: "Reassigns an HR approval step", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public reassign( + @Query() { id, organization, realm }: ReassignQueryDTO, + @Body() input: ReassignBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRApprovalStep.Reassign.Result { + return this.hrApprovalStepCommands.reassign({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("approve") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_APPROVE) + @ApiOperation({ + summary: "Approves an HR approval step", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public approve( + @Query() { id, organization, realm }: ApproveQueryDTO, + @Body() input: ApproveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRApprovalStep.Approve.Result { + return this.hrApprovalStepCommands.approve({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("reject") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_REJECT) + @ApiOperation({ + summary: "Rejects an HR approval step", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public reject( + @Query() { id, organization, realm }: RejectQueryDTO, + @Body() input: RejectBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRApprovalStep.Reject.Result { + return this.hrApprovalStepCommands.reject({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("return-for-revision") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_APPROVAL_STEP_RETURN_FOR_REVISION) + @ApiOperation({ + summary: "Returns an HR approval step for revision", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public returnForRevision( + @Query() { id, organization, realm }: ReturnForRevisionQueryDTO, + @Body() input: ReturnForRevisionBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRApprovalStep.ReturnForRevision.Result { + return this.hrApprovalStepCommands.returnForRevision({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/hr-request.controller.ts b/src/context/interface/controllers/hr-request.controller.ts new file mode 100644 index 0000000..cc728f5 --- /dev/null +++ b/src/context/interface/controllers/hr-request.controller.ts @@ -0,0 +1,152 @@ +import { Controller, HttpStatus, HttpCode, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { HR_REQUEST_COMMANDS } from "~context/application/commands"; +import { HR_REQUEST_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + WithdrawQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + WithdrawBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + SubmitQueryDTO, + UpdateQueryDTO, + CreateBodyDTO, + SubmitBodyDTO, + UpdateBodyDTO, + HRRequestDTO, + ListDTO, +} from "../dto/hr-request"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("HRRequest") +@Controller("/hr-request") +export class HRRequestController { + public constructor( + @Inject(HR_REQUEST_COMMANDS) + private readonly hrRequestCommands: Commands.HRRequest.ControllerContract, + @Inject(HR_REQUEST_QUERIES) + private readonly hrRequestQueries: Queries.HRRequest.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(HRRequestDTO) + @ApiResponse({ status: OK, type: HRRequestDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_READ_ABSOLUTE, PermissionCode.HR_REQUEST_READ_COMMON) + @ApiOperation({ + summary: "Returns a hrrequest by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.HRRequest.FindUnique.Result { + return this.hrRequestQueries.findUnique({ organization, realm, view, request: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_READ_ABSOLUTE, PermissionCode.HR_REQUEST_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of hrrequests", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.HRRequest.FindMany.Result { + return this.hrRequestQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_CREATE) + @ApiOperation({ + summary: "Creates a new hrrequest", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRRequest.Create.Result { + return this.hrRequestCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Patch("update") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_UPDATE) + @ApiOperation({ + summary: "Updates hrrequest metadata", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public update( + @Query() { id, organization, realm }: UpdateQueryDTO, + @Body() input: UpdateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRRequest.Update.Result { + return this.hrRequestCommands.update({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("submit") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_SUBMIT) + @ApiOperation({ + summary: "Submits a hrrequest", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public submit( + @Query() { id, organization, realm }: SubmitQueryDTO, + @Body() input: SubmitBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRRequest.Submit.Result { + return this.hrRequestCommands.submit({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("withdraw") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.HR_REQUEST_WITHDRAW) + @ApiOperation({ + summary: "Withdraws a hrrequest", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public withdraw( + @Query() { id, organization, realm }: WithdrawQueryDTO, + @Body() input: WithdrawBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.HRRequest.Withdraw.Result { + return this.hrRequestCommands.withdraw({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/index.ts b/src/context/interface/controllers/index.ts index f271639..a9ae57f 100644 --- a/src/context/interface/controllers/index.ts +++ b/src/context/interface/controllers/index.ts @@ -1 +1,19 @@ -export const HTTP_CONTROLLERS = []; +import { WorkCalendarExceptionController } from "./work-calendar-exception.controller"; +import { HRApprovalStepController } from "./hr-approval-step.controller"; +import { WorkScheduleController } from "./work-schedule.controller"; +import { WorkCalendarController } from "./work-calendar.controller"; +import { LeavePolicyController } from "./leave-policy.controller"; +import { HRRequestController } from "./hr-request.controller"; +import { EmployeeController } from "./employee.controller"; +import { PositionController } from "./position.controller"; + +export const HTTP_CONTROLLERS = [ + WorkCalendarExceptionController, + HRApprovalStepController, + WorkCalendarController, + WorkScheduleController, + LeavePolicyController, + HRRequestController, + PositionController, + EmployeeController, +]; diff --git a/src/context/interface/controllers/leave-policy.controller.ts b/src/context/interface/controllers/leave-policy.controller.ts new file mode 100644 index 0000000..94af054 --- /dev/null +++ b/src/context/interface/controllers/leave-policy.controller.ts @@ -0,0 +1,173 @@ +import { Controller, HttpStatus, HttpCode, Delete, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { LEAVE_POLICY_COMMANDS } from "~context/application/commands"; +import { LEAVE_POLICY_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + CreateRevisionQueryDTO, + ArchiveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + RestoreQueryDTO, + RevisionBodyDTO, + ArchiveBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + LeavePolicyDTO, + RestoreBodyDTO, + CreateBodyDTO, + PurgeQueryDTO, + PurgeBodyDTO, + ListDTO, +} from "../dto/leave-policy"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("LeavePolicy") +@Controller("/leave-policy") +export class LeavePolicyController { + public constructor( + @Inject(LEAVE_POLICY_COMMANDS) + private readonly leavePolicyCommands: Commands.LeavePolicy.ControllerContract, + @Inject(LEAVE_POLICY_QUERIES) + private readonly leavePolicyQueries: Queries.LeavePolicy.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(LeavePolicyDTO) + @ApiResponse({ status: OK, type: LeavePolicyDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_READ_ABSOLUTE, PermissionCode.LEAVE_POLICY_READ_COMMON) + @ApiOperation({ + summary: "Returns a leave policy by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.LeavePolicy.FindUnique.Result { + return this.leavePolicyQueries.findUnique({ organization, realm, view, policy: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_READ_ABSOLUTE, PermissionCode.LEAVE_POLICY_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of leave policys", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.LeavePolicy.FindMany.Result { + return this.leavePolicyQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_CREATE) + @ApiOperation({ + summary: "Creates a new leave policy", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.LeavePolicy.Create.Result { + return this.leavePolicyCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Post("create-revision") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_CREATE_REVISION) + @ApiOperation({ + summary: "Creates a new revision of a leave policy", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public createRevision( + @Query() { id, organization, realm }: CreateRevisionQueryDTO, + @Body() input: RevisionBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.LeavePolicy.CreateRevision.Result { + return this.leavePolicyCommands.createRevision({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("archive") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_ARCHIVE) + @ApiOperation({ + summary: "Archives a leave policy", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public archive( + @Query() { id, organization, realm }: ArchiveQueryDTO, + @Body() input: ArchiveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.LeavePolicy.Archive.Result { + return this.leavePolicyCommands.archive({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("restore") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_RESTORE) + @ApiOperation({ + summary: "Restores a leave policy", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public restore( + @Query() { id, organization, realm }: RestoreQueryDTO, + @Body() input: RestoreBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.LeavePolicy.Restore.Result { + return this.leavePolicyCommands.restore({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Delete("purge") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.LEAVE_POLICY_PURGE) + @ApiOperation({ + summary: "Permanently deletes a revoked leave policy", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public purge( + @Query() { id, organization, realm }: PurgeQueryDTO, + @Body() input: PurgeBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.LeavePolicy.Purge.Result { + return this.leavePolicyCommands.purge({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/position.controller.ts b/src/context/interface/controllers/position.controller.ts new file mode 100644 index 0000000..8d594e0 --- /dev/null +++ b/src/context/interface/controllers/position.controller.ts @@ -0,0 +1,173 @@ +import { Controller, HttpStatus, HttpCode, Delete, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { POSITION_COMMANDS } from "~context/application/commands"; +import { POSITION_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + ArchiveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + RestoreQueryDTO, + ArchiveBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + RestoreBodyDTO, + UpdateQueryDTO, + CreateBodyDTO, + PurgeQueryDTO, + UpdateBodyDTO, + PurgeBodyDTO, + PositionDTO, + ListDTO, +} from "../dto/position"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("Position") +@Controller("/position") +export class PositionController { + public constructor( + @Inject(POSITION_COMMANDS) + private readonly positionCommands: Commands.Position.ControllerContract, + @Inject(POSITION_QUERIES) + private readonly positionQueries: Queries.Position.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(PositionDTO) + @RequirePermission(PermissionCode.POSITION_READ_ABSOLUTE, PermissionCode.POSITION_READ_COMMON) + @ApiResponse({ status: OK, type: PositionDTO }) + @ApiOperation({ + summary: "Returns a position by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.Position.FindUnique.Result { + return this.positionQueries.findUnique({ organization, realm, view, position: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.POSITION_READ_ABSOLUTE, PermissionCode.POSITION_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of positions", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.Position.FindMany.Result { + return this.positionQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.POSITION_CREATE) + @ApiOperation({ + summary: "Creates a new position", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Position.Create.Result { + return this.positionCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Patch("update") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.POSITION_UPDATE) + @ApiOperation({ + summary: "Updates position metadata", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public update( + @Query() { id, organization, realm }: UpdateQueryDTO, + @Body() input: UpdateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Position.Update.Result { + return this.positionCommands.update({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("archive") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.POSITION_ARCHIVE) + @ApiOperation({ + summary: "Archives a position", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public archive( + @Query() { id, organization, realm }: ArchiveQueryDTO, + @Body() input: ArchiveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Position.Archive.Result { + return this.positionCommands.archive({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("restore") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.POSITION_RESTORE) + @ApiOperation({ + summary: "Restores a position", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public restore( + @Query() { id, organization, realm }: RestoreQueryDTO, + @Body() input: RestoreBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Position.Restore.Result { + return this.positionCommands.restore({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Delete("purge") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.POSITION_PURGE) + @ApiOperation({ + summary: "Permanently deletes a revoked position", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public purge( + @Query() { id, organization, realm }: PurgeQueryDTO, + @Body() input: PurgeBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.Position.Purge.Result { + return this.positionCommands.purge({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/work-calendar-exception.controller.ts b/src/context/interface/controllers/work-calendar-exception.controller.ts new file mode 100644 index 0000000..51d6d2f --- /dev/null +++ b/src/context/interface/controllers/work-calendar-exception.controller.ts @@ -0,0 +1,139 @@ +import { Controller, HttpStatus, HttpCode, Delete, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { WORK_CALENDAR_EXCEPTION_COMMANDS } from "~context/application/commands"; +import { WORK_CALENDAR_EXCEPTION_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + WorkCalendarExceptionDTO, + GetByIdQueryDTO, + GetListQueryDTO, + CreateQueryDTO, + GetListBodyDTO, + UpdateQueryDTO, + CreateBodyDTO, + PurgeQueryDTO, + UpdateBodyDTO, + PurgeBodyDTO, + ListDTO, +} from "../dto/work-calendar-exception"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("WorkCalendarException") +@Controller("/work-calendar-exception") +export class WorkCalendarExceptionController { + public constructor( + @Inject(WORK_CALENDAR_EXCEPTION_COMMANDS) + private readonly workCalendarExceptionCommands: Commands.WorkCalendarException.ControllerContract, + @Inject(WORK_CALENDAR_EXCEPTION_QUERIES) + private readonly workCalendarExceptionQueries: Queries.WorkCalendarException.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(WorkCalendarExceptionDTO) + @ApiResponse({ status: OK, type: WorkCalendarExceptionDTO }) + @RequirePermission( + PermissionCode.WORK_CALENDAR_EXCEPTION_READ_ABSOLUTE, + PermissionCode.WORK_CALENDAR_EXCEPTION_READ_COMMON, + ) + @ApiOperation({ + summary: "Returns a work calendar exception by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique( + @Query() { organization, realm, view, id }: GetByIdQueryDTO, + ): Queries.WorkCalendarException.FindUnique.Result { + return this.workCalendarExceptionQueries.findUnique({ organization, realm, view, exception: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission( + PermissionCode.WORK_CALENDAR_EXCEPTION_READ_ABSOLUTE, + PermissionCode.WORK_CALENDAR_EXCEPTION_READ_COMMON, + ) + @ApiOperation({ + summary: "Returns a paginated list of work calendar exceptions", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.WorkCalendarException.FindMany.Result { + return this.workCalendarExceptionQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_EXCEPTION_CREATE) + @ApiOperation({ + summary: "Creates a new work calendar exception", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendarException.Create.Result { + return this.workCalendarExceptionCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Patch("update") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_EXCEPTION_UPDATE) + @ApiOperation({ + summary: "Updates work calendar exception metadata", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public update( + @Query() { id, organization, realm }: UpdateQueryDTO, + @Body() input: UpdateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendarException.Update.Result { + return this.workCalendarExceptionCommands.update({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Delete("purge") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_EXCEPTION_PURGE) + @ApiOperation({ + summary: "Permanently deletes a revoked work calendar exception", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public purge( + @Query() { id, organization, realm }: PurgeQueryDTO, + @Body() input: PurgeBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendarException.Purge.Result { + return this.workCalendarExceptionCommands.purge({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/work-calendar.controller.ts b/src/context/interface/controllers/work-calendar.controller.ts new file mode 100644 index 0000000..da1bdfa --- /dev/null +++ b/src/context/interface/controllers/work-calendar.controller.ts @@ -0,0 +1,173 @@ +import { Controller, HttpStatus, HttpCode, Delete, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { WORK_CALENDAR_COMMANDS } from "~context/application/commands"; +import { WORK_CALENDAR_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + ArchiveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + RestoreQueryDTO, + WorkCalendarDTO, + ArchiveBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + RestoreBodyDTO, + UpdateQueryDTO, + CreateBodyDTO, + PurgeQueryDTO, + UpdateBodyDTO, + PurgeBodyDTO, + ListDTO, +} from "../dto/work-calendar"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("WorkCalendar") +@Controller("/work-calendar") +export class WorkCalendarController { + public constructor( + @Inject(WORK_CALENDAR_COMMANDS) + private readonly workCalendarCommands: Commands.WorkCalendar.ControllerContract, + @Inject(WORK_CALENDAR_QUERIES) + private readonly workCalendarQueries: Queries.WorkCalendar.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(WorkCalendarDTO) + @ApiResponse({ status: OK, type: WorkCalendarDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_READ_ABSOLUTE, PermissionCode.WORK_CALENDAR_READ_COMMON) + @ApiOperation({ + summary: "Returns a work calendar by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.WorkCalendar.FindUnique.Result { + return this.workCalendarQueries.findUnique({ organization, realm, view, calendar: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_READ_ABSOLUTE, PermissionCode.WORK_CALENDAR_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of work calendars", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.WorkCalendar.FindMany.Result { + return this.workCalendarQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_CREATE) + @ApiOperation({ + summary: "Creates a new work calendar", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendar.Create.Result { + return this.workCalendarCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Patch("update") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_UPDATE) + @ApiOperation({ + summary: "Updates work calendar metadata", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public update( + @Query() { id, organization, realm }: UpdateQueryDTO, + @Body() input: UpdateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendar.Update.Result { + return this.workCalendarCommands.update({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("archive") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_ARCHIVE) + @ApiOperation({ + summary: "Archives a work calendar", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public archive( + @Query() { id, organization, realm }: ArchiveQueryDTO, + @Body() input: ArchiveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendar.Archive.Result { + return this.workCalendarCommands.archive({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("restore") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_RESTORE) + @ApiOperation({ + summary: "Restores a work calendar", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public restore( + @Query() { id, organization, realm }: RestoreQueryDTO, + @Body() input: RestoreBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendar.Restore.Result { + return this.workCalendarCommands.restore({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Delete("purge") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_CALENDAR_PURGE) + @ApiOperation({ + summary: "Permanently deletes a revoked work calendar", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public purge( + @Query() { id, organization, realm }: PurgeQueryDTO, + @Body() input: PurgeBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkCalendar.Purge.Result { + return this.workCalendarCommands.purge({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/controllers/work-schedule.controller.ts b/src/context/interface/controllers/work-schedule.controller.ts new file mode 100644 index 0000000..5970d8a --- /dev/null +++ b/src/context/interface/controllers/work-schedule.controller.ts @@ -0,0 +1,173 @@ +import { Controller, HttpStatus, HttpCode, Delete, Inject, Patch, Query, Body, Post, Get } from "@nestjs/common"; +import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; + +import { RequirePermission, FormatResponse, Swagger, Extract } from "~common/decorators"; +import { WORK_SCHEDULE_COMMANDS } from "~context/application/commands"; +import { WORK_SCHEDULE_QUERIES } from "~context/application/queries"; +import { PermissionCode, QueryMode } from "~context/enums"; +import { SuccessMessageDTO } from "~common/dto"; + +import { + CreateRevisionQueryDTO, + ArchiveQueryDTO, + GetByIdQueryDTO, + GetListQueryDTO, + RestoreQueryDTO, + RevisionBodyDTO, + WorkScheduleDTO, + ArchiveBodyDTO, + CreateQueryDTO, + GetListBodyDTO, + RestoreBodyDTO, + CreateBodyDTO, + PurgeQueryDTO, + PurgeBodyDTO, + ListDTO, +} from "../dto/work-schedule"; + +const { INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CREATED, OK } = HttpStatus; + +@ApiTags("WorkSchedule") +@Controller("/work-schedule") +export class WorkScheduleController { + public constructor( + @Inject(WORK_SCHEDULE_COMMANDS) + private readonly workScheduleCommands: Commands.WorkSchedule.ControllerContract, + @Inject(WORK_SCHEDULE_QUERIES) + private readonly workScheduleQueries: Queries.WorkSchedule.ControllerContract, + ) {} + + @Get() + @HttpCode(OK) + @FormatResponse(WorkScheduleDTO) + @ApiResponse({ status: OK, type: WorkScheduleDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_READ_ABSOLUTE, PermissionCode.WORK_SCHEDULE_READ_COMMON) + @ApiOperation({ + summary: "Returns a work schedule by identifier", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public findUnique(@Query() { organization, realm, view, id }: GetByIdQueryDTO): Queries.WorkSchedule.FindUnique.Result { + return this.workScheduleQueries.findUnique({ organization, realm, view, schedule: id }); + } + + @HttpCode(OK) + @Post("list") + @FormatResponse(ListDTO) + @ApiResponse({ status: OK, type: ListDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_READ_ABSOLUTE, PermissionCode.WORK_SCHEDULE_READ_COMMON) + @ApiOperation({ + summary: "Returns a paginated list of work schedules", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN) + public findMany( + @Query() { organization, realm, view }: GetListQueryDTO, + @Body() { pagination, filters, sort }: GetListBodyDTO, + ): Queries.WorkSchedule.FindMany.Result { + return this.workScheduleQueries.findMany({ + mode: QueryMode.DEFAULT, + organization, + pagination, + filters, + realm, + view, + sort, + }); + } + + @Post("create") + @HttpCode(CREATED) + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: CREATED, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_CREATE) + @ApiOperation({ + summary: "Creates a new work schedule", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public create( + @Query() { organization, realm }: CreateQueryDTO, + @Body() input: CreateBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkSchedule.Create.Result { + return this.workScheduleCommands.create({ organization, context, realm, actor, input }); + } + + @HttpCode(OK) + @Post("create-revision") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_CREATE_REVISION) + @ApiOperation({ + summary: "Creates a new revision of a work schedule", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public createRevision( + @Query() { id, organization, realm }: CreateRevisionQueryDTO, + @Body() input: RevisionBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkSchedule.CreateRevision.Result { + return this.workScheduleCommands.createRevision({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("archive") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_ARCHIVE) + @ApiOperation({ + summary: "Archives a work schedule", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public archive( + @Query() { id, organization, realm }: ArchiveQueryDTO, + @Body() input: ArchiveBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkSchedule.Archive.Result { + return this.workScheduleCommands.archive({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Patch("restore") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_RESTORE) + @ApiOperation({ + summary: "Restores a work schedule", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public restore( + @Query() { id, organization, realm }: RestoreQueryDTO, + @Body() input: RestoreBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkSchedule.Restore.Result { + return this.workScheduleCommands.restore({ organization, context, realm, actor, input, id }); + } + + @HttpCode(OK) + @Delete("purge") + @FormatResponse(SuccessMessageDTO) + @ApiResponse({ status: OK, type: SuccessMessageDTO }) + @RequirePermission(PermissionCode.WORK_SCHEDULE_PURGE) + @ApiOperation({ + summary: "Permanently deletes a revoked work schedule", + security: [{ identity: [] }], + }) + @Swagger.Exceptions(INTERNAL_SERVER_ERROR, UNPROCESSABLE_ENTITY, UNAUTHORIZED, FORBIDDEN, NOT_FOUND) + public purge( + @Query() { id, organization, realm }: PurgeQueryDTO, + @Body() input: PurgeBodyDTO, + @Extract.Session() { account: actor }: Extract.Session.Auth, + @Extract.Meta() context: Extract.Meta, + ): Commands.WorkSchedule.Purge.Result { + return this.workScheduleCommands.purge({ organization, context, realm, actor, input, id }); + } +} diff --git a/src/context/interface/dto/.gitkeep b/src/context/interface/dto/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/context/interface/dto/employee/index.ts b/src/context/interface/dto/employee/index.ts new file mode 100644 index 0000000..7ed480b --- /dev/null +++ b/src/context/interface/dto/employee/index.ts @@ -0,0 +1,15 @@ +export { UnlinkAccountQueryDTO, UnlinkAccountBodyDTO } from "./req/unlink-account.dto"; +export { LinkAccountQueryDTO, LinkAccountBodyDTO } from "./req/link-account.dto"; +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { SetHRBPQueryDTO, SetHrbpBodyDTO } from "./req/set-hrbp.dto"; +export { ArchiveQueryDTO, ArchiveBodyDTO } from "./req/archive.dto"; +export { RestoreQueryDTO, RestoreBodyDTO } from "./req/restore.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { UpdateQueryDTO, UpdateBodyDTO } from "./req/update.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { EmployeeDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/employee/req/archive.dto.ts b/src/context/interface/dto/employee/req/archive.dto.ts new file mode 100644 index 0000000..f519803 --- /dev/null +++ b/src/context/interface/dto/employee/req/archive.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeArchiveBody" }) +export class ArchiveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeArchiveQuery" }) +export class ArchiveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/create.dto.ts b/src/context/interface/dto/employee/req/create.dto.ts new file mode 100644 index 0000000..29f7fbb --- /dev/null +++ b/src/context/interface/dto/employee/req/create.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public employeeNumber: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public middleName?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public workEmail?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public firstName: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public lastName: string; +} + +@ApiSchema({ name: "EmployeeCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/get-by-id.dto.ts b/src/context/interface/dto/employee/req/get-by-id.dto.ts new file mode 100644 index 0000000..1d24b02 --- /dev/null +++ b/src/context/interface/dto/employee/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/get-list.dto.ts b/src/context/interface/dto/employee/req/get-list.dto.ts new file mode 100644 index 0000000..d338233 --- /dev/null +++ b/src/context/interface/dto/employee/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "EmployeeListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "EmployeeListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/link-account.dto.ts b/src/context/interface/dto/employee/req/link-account.dto.ts new file mode 100644 index 0000000..326dede --- /dev/null +++ b/src/context/interface/dto/employee/req/link-account.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeLinkAccountBody" }) +export class LinkAccountBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public account: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeLinkAccountQuery" }) +export class LinkAccountQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/restore.dto.ts b/src/context/interface/dto/employee/req/restore.dto.ts new file mode 100644 index 0000000..758a6c6 --- /dev/null +++ b/src/context/interface/dto/employee/req/restore.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeRestoreBody" }) +export class RestoreBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeRestoreQuery" }) +export class RestoreQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/set-hrbp.dto.ts b/src/context/interface/dto/employee/req/set-hrbp.dto.ts new file mode 100644 index 0000000..d37d8d4 --- /dev/null +++ b/src/context/interface/dto/employee/req/set-hrbp.dto.ts @@ -0,0 +1,36 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeSetHRBPBody" }) +export class SetHrbpBodyDTO { + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public employee?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeSetHRBPQuery" }) +export class SetHRBPQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/unlink-account.dto.ts b/src/context/interface/dto/employee/req/unlink-account.dto.ts new file mode 100644 index 0000000..4fb4038 --- /dev/null +++ b/src/context/interface/dto/employee/req/unlink-account.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeUnlinkAccountBody" }) +export class UnlinkAccountBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeUnlinkAccountQuery" }) +export class UnlinkAccountQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/req/update.dto.ts b/src/context/interface/dto/employee/req/update.dto.ts new file mode 100644 index 0000000..7889140 --- /dev/null +++ b/src/context/interface/dto/employee/req/update.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeUpdateBody" }) +export class UpdateBodyDTO { + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true }) + declare public patch: Partial; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "EmployeeUpdateQuery" }) +export class UpdateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/employee/res/entity.dto.ts b/src/context/interface/dto/employee/res/entity.dto.ts new file mode 100644 index 0000000..9cccbd2 --- /dev/null +++ b/src/context/interface/dto/employee/res/entity.dto.ts @@ -0,0 +1,114 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { EmployeeStatus } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "Employee" }) +export class EmployeeDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public employmentStartedOn?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public scheduleAnchorDate?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public employmentEndedOn?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public scheduleTimezone?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public termsValidFrom?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public contractEndsOn?: string; + + @Expose() + @Validator.IsEnum(EmployeeStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: EmployeeStatus; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public employeeNumber: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public contractType?: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public termsRevision: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public middleName?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public workEmail?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public firstName: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public lastName: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public account?: string; +} diff --git a/src/context/interface/dto/employee/res/list.dto.ts b/src/context/interface/dto/employee/res/list.dto.ts new file mode 100644 index 0000000..b4185b5 --- /dev/null +++ b/src/context/interface/dto/employee/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { EmployeeDTO } from "./entity.dto"; + +@ApiSchema({ name: "EmployeeListMeta" }) +class EmployeeListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "EmployeeList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => EmployeeDTO) + @ApiProperty({ required: true, type: [EmployeeDTO] }) + declare public data: EmployeeDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => EmployeeListMetaDTO) + @ApiProperty({ required: false, type: EmployeeListMetaDTO }) + declare public meta?: EmployeeListMetaDTO; +} diff --git a/src/context/interface/dto/employee/utils/filters.dto.ts b/src/context/interface/dto/employee/utils/filters.dto.ts new file mode 100644 index 0000000..4062c01 --- /dev/null +++ b/src/context/interface/dto/employee/utils/filters.dto.ts @@ -0,0 +1,176 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeFilters" }) +export class FiltersDTO implements Repositories.Mappers.Employee.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public scheduleTimezone?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public employeeNumber?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public contractType?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public middleName?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public workEmail?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public firstName?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public lastName?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public employmentStartedOn?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public scheduleAnchorDate?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public employmentEndedOn?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public termsValidFrom?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public contractEndsOn?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public termsRevision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public workCalendar?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public workSchedule?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public hrBpEmployee?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public leavePolicy?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public account?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/employee/utils/sort.dto.ts b/src/context/interface/dto/employee/utils/sort.dto.ts new file mode 100644 index 0000000..628029b --- /dev/null +++ b/src/context/interface/dto/employee/utils/sort.dto.ts @@ -0,0 +1,62 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "EmployeeSort" }) +export class SortDTO implements Repositories.Mappers.Employee.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public employmentStartedOn?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public scheduleAnchorDate?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public employmentEndedOn?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public termsValidFrom?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public contractEndsOn?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public termsRevision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +} diff --git a/src/context/interface/dto/hr-approval-step/index.ts b/src/context/interface/dto/hr-approval-step/index.ts new file mode 100644 index 0000000..74910d4 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/index.ts @@ -0,0 +1,12 @@ +export { ReturnForRevisionQueryDTO, ReturnForRevisionBodyDTO } from "./req/return-for-revision.dto"; +export { ReassignQueryDTO, ReassignBodyDTO } from "./req/reassign.dto"; +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { ApproveQueryDTO, ApproveBodyDTO } from "./req/approve.dto"; +export { RejectQueryDTO, RejectBodyDTO } from "./req/reject.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { HRApprovalStepDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/hr-approval-step/req/approve.dto.ts b/src/context/interface/dto/hr-approval-step/req/approve.dto.ts new file mode 100644 index 0000000..44ef0ba --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/approve.dto.ts @@ -0,0 +1,41 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepApproveBody" }) +export class ApproveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public actorEmployee: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public comment?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "HRApprovalStepApproveQuery" }) +export class ApproveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/req/get-by-id.dto.ts b/src/context/interface/dto/hr-approval-step/req/get-by-id.dto.ts new file mode 100644 index 0000000..efd97d2 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/req/get-list.dto.ts b/src/context/interface/dto/hr-approval-step/req/get-list.dto.ts new file mode 100644 index 0000000..888d3bc --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "HRApprovalStepListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "HRApprovalStepListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/req/reassign.dto.ts b/src/context/interface/dto/hr-approval-step/req/reassign.dto.ts new file mode 100644 index 0000000..df9e199 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/reassign.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepReassignBody" }) +export class ReassignBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public employee: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "HRApprovalStepReassignQuery" }) +export class ReassignQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/req/reject.dto.ts b/src/context/interface/dto/hr-approval-step/req/reject.dto.ts new file mode 100644 index 0000000..e4b0585 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/reject.dto.ts @@ -0,0 +1,41 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepRejectBody" }) +export class RejectBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public actorEmployee: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public comment?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "HRApprovalStepRejectQuery" }) +export class RejectQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/req/return-for-revision.dto.ts b/src/context/interface/dto/hr-approval-step/req/return-for-revision.dto.ts new file mode 100644 index 0000000..87aef76 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/req/return-for-revision.dto.ts @@ -0,0 +1,41 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepReturnForRevisionBody" }) +export class ReturnForRevisionBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public actorEmployee: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public comment?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "HRApprovalStepReturnForRevisionQuery" }) +export class ReturnForRevisionQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-approval-step/res/entity.dto.ts b/src/context/interface/dto/hr-approval-step/res/entity.dto.ts new file mode 100644 index 0000000..e1b4787 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/res/entity.dto.ts @@ -0,0 +1,61 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { HRApprovalStatus } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStep" }) +export class HRApprovalStepDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsEnum(HRApprovalStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: HRApprovalStatus; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public requestRevision: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public resolvedAt?: Date; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public ordinal: number; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public name: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public dueAt?: Date; +} diff --git a/src/context/interface/dto/hr-approval-step/res/list.dto.ts b/src/context/interface/dto/hr-approval-step/res/list.dto.ts new file mode 100644 index 0000000..3633d30 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { HRApprovalStepDTO } from "./entity.dto"; + +@ApiSchema({ name: "HRApprovalStepListMeta" }) +class HRApprovalStepListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "HRApprovalStepList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => HRApprovalStepDTO) + @ApiProperty({ required: true, type: [HRApprovalStepDTO] }) + declare public data: HRApprovalStepDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => HRApprovalStepListMetaDTO) + @ApiProperty({ required: false, type: HRApprovalStepListMetaDTO }) + declare public meta?: HRApprovalStepListMetaDTO; +} diff --git a/src/context/interface/dto/hr-approval-step/utils/filters.dto.ts b/src/context/interface/dto/hr-approval-step/utils/filters.dto.ts new file mode 100644 index 0000000..5dd54f2 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/utils/filters.dto.ts @@ -0,0 +1,106 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepFilters" }) +export class FiltersDTO implements Repositories.Mappers.HRApprovalStep.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public name?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public requestRevision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public resolvedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public ordinal?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public dueAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public assigneeEmployee?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public decision?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public request?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/hr-approval-step/utils/sort.dto.ts b/src/context/interface/dto/hr-approval-step/utils/sort.dto.ts new file mode 100644 index 0000000..7cf29a8 --- /dev/null +++ b/src/context/interface/dto/hr-approval-step/utils/sort.dto.ts @@ -0,0 +1,50 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRApprovalStepSort" }) +export class SortDTO implements Repositories.Mappers.HRApprovalStep.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public requestRevision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public resolvedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public ordinal?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public dueAt?: QueryOrder; +} diff --git a/src/context/interface/dto/hr-request/index.ts b/src/context/interface/dto/hr-request/index.ts new file mode 100644 index 0000000..65cb76e --- /dev/null +++ b/src/context/interface/dto/hr-request/index.ts @@ -0,0 +1,12 @@ +export { WithdrawQueryDTO, WithdrawBodyDTO } from "./req/withdraw.dto"; +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { SubmitQueryDTO, SubmitBodyDTO } from "./req/submit.dto"; +export { UpdateQueryDTO, UpdateBodyDTO } from "./req/update.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { HRRequestDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/hr-request/req/create.dto.ts b/src/context/interface/dto/hr-request/req/create.dto.ts new file mode 100644 index 0000000..fa7176f --- /dev/null +++ b/src/context/interface/dto/hr-request/req/create.dto.ts @@ -0,0 +1,70 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { HRRequestType } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsNumber() + @ApiProperty({ required: true }) + declare public payloadSchemaVersion: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public initiatorEmployee?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public relatedRequest?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public targetPosition?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public idempotencyKey: string; + + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true, type: Object }) + declare public payload: UnknownObject; + + @Expose() + @Validator.IsEnum(HRRequestType) + @ApiProperty({ required: true }) + declare public type: HRRequestType; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false }) + declare public effectiveAt?: Date; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public employee: string; +} + +@ApiSchema({ name: "HRRequestCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/req/get-by-id.dto.ts b/src/context/interface/dto/hr-request/req/get-by-id.dto.ts new file mode 100644 index 0000000..69074c3 --- /dev/null +++ b/src/context/interface/dto/hr-request/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/req/get-list.dto.ts b/src/context/interface/dto/hr-request/req/get-list.dto.ts new file mode 100644 index 0000000..c0170de --- /dev/null +++ b/src/context/interface/dto/hr-request/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "HRRequestListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "HRRequestListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/req/submit.dto.ts b/src/context/interface/dto/hr-request/req/submit.dto.ts new file mode 100644 index 0000000..5295e5f --- /dev/null +++ b/src/context/interface/dto/hr-request/req/submit.dto.ts @@ -0,0 +1,60 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestWorkflowStep" }) +export class HRRequestWorkflowStepDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public assigneeEmployee: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public dueAt?: Date; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public name: string; +} + +@ApiSchema({ name: "HRRequestSubmitBody" }) +export class SubmitBodyDTO { + @Expose() + @Validator.IsNumber() + @ApiProperty({ required: true, type: Number }) + declare public workflowVersion: number; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public workflowCode: string; + + @Expose() + @Validator.IsArray() + @Type(() => HRRequestWorkflowStepDTO) + @ApiProperty({ required: true, type: () => [HRRequestWorkflowStepDTO] }) + declare public steps: HRRequestWorkflowStepDTO[]; +} + +@ApiSchema({ name: "HRRequestSubmitQuery" }) +export class SubmitQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/req/update.dto.ts b/src/context/interface/dto/hr-request/req/update.dto.ts new file mode 100644 index 0000000..1aa0743 --- /dev/null +++ b/src/context/interface/dto/hr-request/req/update.dto.ts @@ -0,0 +1,39 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestUpdateBody" }) +export class UpdateBodyDTO { + @Expose() + @Validator.IsObject() + @Type(() => Object) + @ApiProperty({ required: true, type: Object }) + declare public patch: Partial> & { + targetPosition?: string; + relatedRequest?: string; + }; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "HRRequestUpdateQuery" }) +export class UpdateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/req/withdraw.dto.ts b/src/context/interface/dto/hr-request/req/withdraw.dto.ts new file mode 100644 index 0000000..c1b8b0a --- /dev/null +++ b/src/context/interface/dto/hr-request/req/withdraw.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestWithdrawBody" }) +export class WithdrawBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "HRRequestWithdrawQuery" }) +export class WithdrawQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/hr-request/res/entity.dto.ts b/src/context/interface/dto/hr-request/res/entity.dto.ts new file mode 100644 index 0000000..4b157f3 --- /dev/null +++ b/src/context/interface/dto/hr-request/res/entity.dto.ts @@ -0,0 +1,129 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { HRExecutionStatus, HRRequestStatus, HRRequestType } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequest" }) +export class HRRequestDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsEnum(HRExecutionStatus) + @ApiProperty({ required: true, type: Object }) + declare public executionStatus: HRExecutionStatus; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public payloadSchemaVersion: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsInt() + @ApiProperty({ required: false, type: Number }) + declare public approvedRevision?: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsInt() + @ApiProperty({ required: false, type: Number }) + declare public workflowVersion?: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsInt() + @ApiProperty({ required: false, type: Number }) + declare public appliedRevision?: number; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public initiatorAccount: string; + + @Expose() + @Validator.IsEnum(HRRequestStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: HRRequestStatus; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public idempotencyKey: string; + + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true, type: Object }) + declare public payload: UnknownObject; + + @Expose() + @Validator.IsOptional() + @Validator.IsObject() + @ApiProperty({ required: false, type: Object }) + declare public result?: UnknownObject; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public workflowCode?: string; + + @Expose() + @Validator.IsEnum(HRRequestType) + @ApiProperty({ required: true, type: Object }) + declare public type: HRRequestType; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public effectiveAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public submittedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public approvedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public appliedAt?: Date; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public revision: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public failure?: string; +} diff --git a/src/context/interface/dto/hr-request/res/list.dto.ts b/src/context/interface/dto/hr-request/res/list.dto.ts new file mode 100644 index 0000000..a9ec045 --- /dev/null +++ b/src/context/interface/dto/hr-request/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { HRRequestDTO } from "./entity.dto"; + +@ApiSchema({ name: "HRRequestListMeta" }) +class HRRequestListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "HRRequestList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => HRRequestDTO) + @ApiProperty({ required: true, type: [HRRequestDTO] }) + declare public data: HRRequestDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => HRRequestListMetaDTO) + @ApiProperty({ required: false, type: HRRequestListMetaDTO }) + declare public meta?: HRRequestListMetaDTO; +} diff --git a/src/context/interface/dto/hr-request/utils/filters.dto.ts b/src/context/interface/dto/hr-request/utils/filters.dto.ts new file mode 100644 index 0000000..f197cc3 --- /dev/null +++ b/src/context/interface/dto/hr-request/utils/filters.dto.ts @@ -0,0 +1,183 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestFilters" }) +export class FiltersDTO implements Repositories.Mappers.HRRequest.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public executionStatus?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public idempotencyKey?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public workflowCode?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public failure?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public type?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public payloadSchemaVersion?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public approvedRevision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public workflowVersion?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public appliedRevision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public effectiveAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public submittedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public approvedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public revision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public appliedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public initiatorEmployee?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public initiatorAccount?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public relatedRequest?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public targetPosition?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public employee?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/hr-request/utils/sort.dto.ts b/src/context/interface/dto/hr-request/utils/sort.dto.ts new file mode 100644 index 0000000..841d369 --- /dev/null +++ b/src/context/interface/dto/hr-request/utils/sort.dto.ts @@ -0,0 +1,80 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "HRRequestSort" }) +export class SortDTO implements Repositories.Mappers.HRRequest.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public payloadSchemaVersion?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public approvedRevision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public workflowVersion?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public appliedRevision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public effectiveAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public submittedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public approvedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public appliedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public revision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +} diff --git a/src/context/interface/dto/leave-policy/index.ts b/src/context/interface/dto/leave-policy/index.ts new file mode 100644 index 0000000..985dba6 --- /dev/null +++ b/src/context/interface/dto/leave-policy/index.ts @@ -0,0 +1,13 @@ +export { CreateRevisionQueryDTO, RevisionBodyDTO } from "./req/revision.dto"; +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { ArchiveQueryDTO, ArchiveBodyDTO } from "./req/archive.dto"; +export { RestoreQueryDTO, RestoreBodyDTO } from "./req/restore.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { PurgeQueryDTO, PurgeBodyDTO } from "./req/purge.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { LeavePolicyDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/leave-policy/req/archive.dto.ts b/src/context/interface/dto/leave-policy/req/archive.dto.ts new file mode 100644 index 0000000..1dc335b --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/archive.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyArchiveBody" }) +export class ArchiveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "LeavePolicyArchiveQuery" }) +export class ArchiveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/create.dto.ts b/src/context/interface/dto/leave-policy/req/create.dto.ts new file mode 100644 index 0000000..a68013e --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/create.dto.ts @@ -0,0 +1,40 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsArray() + @ApiProperty({ required: true }) + declare public rules: Entities.LeavePolicy.Rule[]; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public jurisdiction: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public name: string; +} + +@ApiSchema({ name: "LeavePolicyCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/get-by-id.dto.ts b/src/context/interface/dto/leave-policy/req/get-by-id.dto.ts new file mode 100644 index 0000000..a914c68 --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/get-list.dto.ts b/src/context/interface/dto/leave-policy/req/get-list.dto.ts new file mode 100644 index 0000000..552f5e3 --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "LeavePolicyListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "LeavePolicyListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/purge.dto.ts b/src/context/interface/dto/leave-policy/req/purge.dto.ts new file mode 100644 index 0000000..4e11e31 --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/purge.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyPurgeBody" }) +export class PurgeBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "LeavePolicyPurgeQuery" }) +export class PurgeQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/restore.dto.ts b/src/context/interface/dto/leave-policy/req/restore.dto.ts new file mode 100644 index 0000000..09eca1d --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/restore.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyRestoreBody" }) +export class RestoreBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "LeavePolicyRestoreQuery" }) +export class RestoreQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/req/revision.dto.ts b/src/context/interface/dto/leave-policy/req/revision.dto.ts new file mode 100644 index 0000000..522c94c --- /dev/null +++ b/src/context/interface/dto/leave-policy/req/revision.dto.ts @@ -0,0 +1,43 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyCreateRevisionBody" }) +export class RevisionBodyDTO { + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public name?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public jurisdiction?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsArray() + @ApiProperty({ required: false, type: Array }) + declare public rules?: Entities.LeavePolicy.Rule[]; +} + +@ApiSchema({ name: "LeavePolicyCreateRevisionQuery" }) +export class CreateRevisionQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/leave-policy/res/entity.dto.ts b/src/context/interface/dto/leave-policy/res/entity.dto.ts new file mode 100644 index 0000000..cdc5a94 --- /dev/null +++ b/src/context/interface/dto/leave-policy/res/entity.dto.ts @@ -0,0 +1,59 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { RecordStatus } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicy" }) +export class LeavePolicyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsEnum(RecordStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: RecordStatus; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public jurisdiction: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public revision: number; + + @Expose() + @Validator.IsArray() + @ApiProperty({ required: true, type: Object }) + declare public rules: Entities.LeavePolicy.Rule[]; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public name: string; +} diff --git a/src/context/interface/dto/leave-policy/res/list.dto.ts b/src/context/interface/dto/leave-policy/res/list.dto.ts new file mode 100644 index 0000000..90fd85c --- /dev/null +++ b/src/context/interface/dto/leave-policy/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { LeavePolicyDTO } from "./entity.dto"; + +@ApiSchema({ name: "LeavePolicyListMeta" }) +class LeavePolicyListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "LeavePolicyList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => LeavePolicyDTO) + @ApiProperty({ required: true, type: [LeavePolicyDTO] }) + declare public data: LeavePolicyDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LeavePolicyListMetaDTO) + @ApiProperty({ required: false, type: LeavePolicyListMetaDTO }) + declare public meta?: LeavePolicyListMetaDTO; +} diff --git a/src/context/interface/dto/leave-policy/utils/filters.dto.ts b/src/context/interface/dto/leave-policy/utils/filters.dto.ts new file mode 100644 index 0000000..0708fde --- /dev/null +++ b/src/context/interface/dto/leave-policy/utils/filters.dto.ts @@ -0,0 +1,78 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicyFilters" }) +export class FiltersDTO implements Repositories.Mappers.LeavePolicy.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public jurisdiction?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public code?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public name?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public revision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/leave-policy/utils/sort.dto.ts b/src/context/interface/dto/leave-policy/utils/sort.dto.ts new file mode 100644 index 0000000..4ee9e16 --- /dev/null +++ b/src/context/interface/dto/leave-policy/utils/sort.dto.ts @@ -0,0 +1,32 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "LeavePolicySort" }) +export class SortDTO implements Repositories.Mappers.LeavePolicy.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public revision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +} diff --git a/src/context/interface/dto/position/index.ts b/src/context/interface/dto/position/index.ts new file mode 100644 index 0000000..078fff4 --- /dev/null +++ b/src/context/interface/dto/position/index.ts @@ -0,0 +1,13 @@ +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { ArchiveQueryDTO, ArchiveBodyDTO } from "./req/archive.dto"; +export { RestoreQueryDTO, RestoreBodyDTO } from "./req/restore.dto"; +export { UpdateQueryDTO, UpdateBodyDTO } from "./req/update.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { PurgeQueryDTO, PurgeBodyDTO } from "./req/purge.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { PositionDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/position/req/archive.dto.ts b/src/context/interface/dto/position/req/archive.dto.ts new file mode 100644 index 0000000..7f27f8e --- /dev/null +++ b/src/context/interface/dto/position/req/archive.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionArchiveBody" }) +export class ArchiveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "PositionArchiveQuery" }) +export class ArchiveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/create.dto.ts b/src/context/interface/dto/position/req/create.dto.ts new file mode 100644 index 0000000..8eb5487 --- /dev/null +++ b/src/context/interface/dto/position/req/create.dto.ts @@ -0,0 +1,82 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; +import { PayPeriod } from "~context/enums"; + +@ApiSchema({ name: "PositionCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(PayPeriod) + @ApiProperty({ required: false }) + declare public budgetPeriod?: PayPeriod; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public budgetCurrency?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public budgetAmount?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public requirements?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public description?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public department: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public plannedFte: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public grade?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public title: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public team: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public code: string; +} + +@ApiSchema({ name: "PositionCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/get-by-id.dto.ts b/src/context/interface/dto/position/req/get-by-id.dto.ts new file mode 100644 index 0000000..4e729cc --- /dev/null +++ b/src/context/interface/dto/position/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/get-list.dto.ts b/src/context/interface/dto/position/req/get-list.dto.ts new file mode 100644 index 0000000..2df63f5 --- /dev/null +++ b/src/context/interface/dto/position/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "PositionListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "PositionListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/purge.dto.ts b/src/context/interface/dto/position/req/purge.dto.ts new file mode 100644 index 0000000..aa23291 --- /dev/null +++ b/src/context/interface/dto/position/req/purge.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionPurgeBody" }) +export class PurgeBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "PositionPurgeQuery" }) +export class PurgeQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/restore.dto.ts b/src/context/interface/dto/position/req/restore.dto.ts new file mode 100644 index 0000000..9134772 --- /dev/null +++ b/src/context/interface/dto/position/req/restore.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionRestoreBody" }) +export class RestoreBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "PositionRestoreQuery" }) +export class RestoreQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/req/update.dto.ts b/src/context/interface/dto/position/req/update.dto.ts new file mode 100644 index 0000000..a48bcd7 --- /dev/null +++ b/src/context/interface/dto/position/req/update.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionUpdateBody" }) +export class UpdateBodyDTO { + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true }) + declare public patch: Partial; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "PositionUpdateQuery" }) +export class UpdateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/position/res/entity.dto.ts b/src/context/interface/dto/position/res/entity.dto.ts new file mode 100644 index 0000000..515ba08 --- /dev/null +++ b/src/context/interface/dto/position/res/entity.dto.ts @@ -0,0 +1,107 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { RecordStatus, PayPeriod } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "Position" }) +export class PositionDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(RecordStatus) + @ApiProperty({ required: false, type: Object }) + declare public previousStatus?: RecordStatus; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(PayPeriod) + @ApiProperty({ required: false, type: Object }) + declare public budgetPeriod?: PayPeriod; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public budgetCurrency?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public budgetAmount?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public requirements?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public description?: string; + + @Expose() + @Validator.IsEnum(RecordStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: RecordStatus; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public department: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public plannedFte: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public process?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public grade?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public title: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public team: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public code: string; +} diff --git a/src/context/interface/dto/position/res/list.dto.ts b/src/context/interface/dto/position/res/list.dto.ts new file mode 100644 index 0000000..fe44d26 --- /dev/null +++ b/src/context/interface/dto/position/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { PositionDTO } from "./entity.dto"; + +@ApiSchema({ name: "PositionListMeta" }) +class PositionListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "PositionList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => PositionDTO) + @ApiProperty({ required: true, type: [PositionDTO] }) + declare public data: PositionDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => PositionListMetaDTO) + @ApiProperty({ required: false, type: PositionListMetaDTO }) + declare public meta?: PositionListMetaDTO; +} diff --git a/src/context/interface/dto/position/utils/filters.dto.ts b/src/context/interface/dto/position/utils/filters.dto.ts new file mode 100644 index 0000000..3283293 --- /dev/null +++ b/src/context/interface/dto/position/utils/filters.dto.ts @@ -0,0 +1,127 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionFilters" }) +export class FiltersDTO implements Repositories.Mappers.Position.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public budgetCurrency?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public budgetPeriod?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public requirements?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public description?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public grade?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public title?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public code?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public budgetAmount?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public plannedFte?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public department?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public team?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/position/utils/sort.dto.ts b/src/context/interface/dto/position/utils/sort.dto.ts new file mode 100644 index 0000000..ee82a7b --- /dev/null +++ b/src/context/interface/dto/position/utils/sort.dto.ts @@ -0,0 +1,38 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "PositionSort" }) +export class SortDTO implements Repositories.Mappers.Position.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public budgetAmount?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public plannedFte?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +} diff --git a/src/context/interface/dto/work-calendar-exception/index.ts b/src/context/interface/dto/work-calendar-exception/index.ts new file mode 100644 index 0000000..061ee4d --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/index.ts @@ -0,0 +1,11 @@ +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { UpdateQueryDTO, UpdateBodyDTO } from "./req/update.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { PurgeQueryDTO, PurgeBodyDTO } from "./req/purge.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { WorkCalendarExceptionDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/work-calendar-exception/req/create.dto.ts b/src/context/interface/dto/work-calendar-exception/req/create.dto.ts new file mode 100644 index 0000000..fe9f211 --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/req/create.dto.ts @@ -0,0 +1,61 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; +import { DayOverride } from "~context/enums"; + +@ApiSchema({ name: "WorkCalendarExceptionCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(DayOverride) + @ApiProperty({ required: false }) + declare public workdayOverride?: DayOverride; + + @Expose() + @Validator.IsOptional() + @Validator.IsNumber() + @ApiProperty({ required: false }) + declare public shortenedByMinutes?: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsBoolean() + @ApiProperty({ required: false }) + declare public holidayOverride?: boolean; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public calendar: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public source?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public name?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public date: string; +} + +@ApiSchema({ name: "WorkCalendarExceptionCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/req/get-by-id.dto.ts b/src/context/interface/dto/work-calendar-exception/req/get-by-id.dto.ts new file mode 100644 index 0000000..5641add --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarExceptionGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/req/get-list.dto.ts b/src/context/interface/dto/work-calendar-exception/req/get-list.dto.ts new file mode 100644 index 0000000..7c9c69b --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "WorkCalendarExceptionListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "WorkCalendarExceptionListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/req/purge.dto.ts b/src/context/interface/dto/work-calendar-exception/req/purge.dto.ts new file mode 100644 index 0000000..7937847 --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/req/purge.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarExceptionPurgeBody" }) +export class PurgeBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarExceptionPurgeQuery" }) +export class PurgeQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/req/update.dto.ts b/src/context/interface/dto/work-calendar-exception/req/update.dto.ts new file mode 100644 index 0000000..f0c5fc1 --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/req/update.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarExceptionUpdateBody" }) +export class UpdateBodyDTO { + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true }) + declare public patch: Partial; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarExceptionUpdateQuery" }) +export class UpdateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/res/entity.dto.ts b/src/context/interface/dto/work-calendar-exception/res/entity.dto.ts new file mode 100644 index 0000000..c8c28c1 --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/res/entity.dto.ts @@ -0,0 +1,64 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; +import { DayOverride } from "~context/enums"; + +@ApiSchema({ name: "WorkCalendarException" }) +export class WorkCalendarExceptionDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(DayOverride) + @ApiProperty({ required: false, type: Object }) + declare public workdayOverride?: DayOverride; + + @Expose() + @Validator.IsOptional() + @Validator.IsInt() + @ApiProperty({ required: false, type: Number }) + declare public shortenedByMinutes?: number; + + @Expose() + @Validator.IsOptional() + @Validator.IsBoolean() + @ApiProperty({ required: false, type: Boolean }) + declare public holidayOverride?: boolean; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public source?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public name?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public date: string; +} diff --git a/src/context/interface/dto/work-calendar-exception/res/list.dto.ts b/src/context/interface/dto/work-calendar-exception/res/list.dto.ts new file mode 100644 index 0000000..ea402ff --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { WorkCalendarExceptionDTO } from "./entity.dto"; + +@ApiSchema({ name: "WorkCalendarExceptionListMeta" }) +class WorkCalendarExceptionListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "WorkCalendarExceptionList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => WorkCalendarExceptionDTO) + @ApiProperty({ required: true, type: [WorkCalendarExceptionDTO] }) + declare public data: WorkCalendarExceptionDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => WorkCalendarExceptionListMetaDTO) + @ApiProperty({ required: false, type: WorkCalendarExceptionListMetaDTO }) + declare public meta?: WorkCalendarExceptionListMetaDTO; +} diff --git a/src/context/interface/dto/work-calendar-exception/utils/filters.dto.ts b/src/context/interface/dto/work-calendar-exception/utils/filters.dto.ts new file mode 100644 index 0000000..5173874 --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/utils/filters.dto.ts @@ -0,0 +1,91 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarExceptionFilters" }) +export class FiltersDTO implements Repositories.Mappers.WorkCalendarException.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public workdayOverride?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public source?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public name?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public shortenedByMinutes?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public date?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.IsBoolean() + @ApiProperty({ required: false, type: Boolean }) + public holidayOverride?: boolean; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public calendar?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/work-calendar-exception/utils/sort.dto.ts b/src/context/interface/dto/work-calendar-exception/utils/sort.dto.ts new file mode 100644 index 0000000..ca1223a --- /dev/null +++ b/src/context/interface/dto/work-calendar-exception/utils/sort.dto.ts @@ -0,0 +1,38 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarExceptionSort" }) +export class SortDTO implements Repositories.Mappers.WorkCalendarException.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public shortenedByMinutes?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public date?: QueryOrder; +} diff --git a/src/context/interface/dto/work-calendar/index.ts b/src/context/interface/dto/work-calendar/index.ts new file mode 100644 index 0000000..d645e98 --- /dev/null +++ b/src/context/interface/dto/work-calendar/index.ts @@ -0,0 +1,13 @@ +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { ArchiveQueryDTO, ArchiveBodyDTO } from "./req/archive.dto"; +export { RestoreQueryDTO, RestoreBodyDTO } from "./req/restore.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { UpdateQueryDTO, UpdateBodyDTO } from "./req/update.dto"; +export { PurgeQueryDTO, PurgeBodyDTO } from "./req/purge.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { WorkCalendarDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/work-calendar/req/archive.dto.ts b/src/context/interface/dto/work-calendar/req/archive.dto.ts new file mode 100644 index 0000000..6c523fd --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/archive.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarArchiveBody" }) +export class ArchiveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarArchiveQuery" }) +export class ArchiveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/create.dto.ts b/src/context/interface/dto/work-calendar/req/create.dto.ts new file mode 100644 index 0000000..86c6eb3 --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/create.dto.ts @@ -0,0 +1,52 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsArray() + @ApiProperty({ required: true }) + declare public holidays: Entities.WorkCalendar.Holiday[]; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public verifiedThrough?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public countryCode: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false }) + declare public regionCode?: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public name: string; +} + +@ApiSchema({ name: "WorkCalendarCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/get-by-id.dto.ts b/src/context/interface/dto/work-calendar/req/get-by-id.dto.ts new file mode 100644 index 0000000..3a553e2 --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/get-list.dto.ts b/src/context/interface/dto/work-calendar/req/get-list.dto.ts new file mode 100644 index 0000000..9a260e3 --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "WorkCalendarListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "WorkCalendarListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/purge.dto.ts b/src/context/interface/dto/work-calendar/req/purge.dto.ts new file mode 100644 index 0000000..aa4c3e7 --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/purge.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarPurgeBody" }) +export class PurgeBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarPurgeQuery" }) +export class PurgeQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/restore.dto.ts b/src/context/interface/dto/work-calendar/req/restore.dto.ts new file mode 100644 index 0000000..90ceb27 --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/restore.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarRestoreBody" }) +export class RestoreBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarRestoreQuery" }) +export class RestoreQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/req/update.dto.ts b/src/context/interface/dto/work-calendar/req/update.dto.ts new file mode 100644 index 0000000..bdcc61e --- /dev/null +++ b/src/context/interface/dto/work-calendar/req/update.dto.ts @@ -0,0 +1,35 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarUpdateBody" }) +export class UpdateBodyDTO { + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true }) + declare public patch: Partial; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkCalendarUpdateQuery" }) +export class UpdateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-calendar/res/entity.dto.ts b/src/context/interface/dto/work-calendar/res/entity.dto.ts new file mode 100644 index 0000000..06b4558 --- /dev/null +++ b/src/context/interface/dto/work-calendar/res/entity.dto.ts @@ -0,0 +1,66 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; +import { RecordStatus } from "~context/enums"; + +@ApiSchema({ name: "WorkCalendar" }) +export class WorkCalendarDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public verifiedThrough?: string; + + @Expose() + @Validator.IsEnum(RecordStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: RecordStatus; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public countryCode: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public regionCode?: string; + + @Expose() + @Validator.IsArray() + @ApiProperty({ required: true, type: Object }) + declare public holidays: Entities.WorkCalendar.Holiday[]; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public name: string; +} diff --git a/src/context/interface/dto/work-calendar/res/list.dto.ts b/src/context/interface/dto/work-calendar/res/list.dto.ts new file mode 100644 index 0000000..ea3dbfe --- /dev/null +++ b/src/context/interface/dto/work-calendar/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { WorkCalendarDTO } from "./entity.dto"; + +@ApiSchema({ name: "WorkCalendarListMeta" }) +class WorkCalendarListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "WorkCalendarList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => WorkCalendarDTO) + @ApiProperty({ required: true, type: [WorkCalendarDTO] }) + declare public data: WorkCalendarDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => WorkCalendarListMetaDTO) + @ApiProperty({ required: false, type: WorkCalendarListMetaDTO }) + declare public meta?: WorkCalendarListMetaDTO; +} diff --git a/src/context/interface/dto/work-calendar/utils/filters.dto.ts b/src/context/interface/dto/work-calendar/utils/filters.dto.ts new file mode 100644 index 0000000..ae559d9 --- /dev/null +++ b/src/context/interface/dto/work-calendar/utils/filters.dto.ts @@ -0,0 +1,85 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarFilters" }) +export class FiltersDTO implements Repositories.Mappers.WorkCalendar.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public countryCode?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public regionCode?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public code?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public name?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public verifiedThrough?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/work-calendar/utils/sort.dto.ts b/src/context/interface/dto/work-calendar/utils/sort.dto.ts new file mode 100644 index 0000000..151b239 --- /dev/null +++ b/src/context/interface/dto/work-calendar/utils/sort.dto.ts @@ -0,0 +1,32 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkCalendarSort" }) +export class SortDTO implements Repositories.Mappers.WorkCalendar.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public verifiedThrough?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +} diff --git a/src/context/interface/dto/work-schedule/index.ts b/src/context/interface/dto/work-schedule/index.ts new file mode 100644 index 0000000..1bab248 --- /dev/null +++ b/src/context/interface/dto/work-schedule/index.ts @@ -0,0 +1,13 @@ +export { CreateRevisionQueryDTO, RevisionBodyDTO } from "./req/revision.dto"; +export { GetListQueryDTO, GetListBodyDTO } from "./req/get-list.dto"; +export { ArchiveQueryDTO, ArchiveBodyDTO } from "./req/archive.dto"; +export { RestoreQueryDTO, RestoreBodyDTO } from "./req/restore.dto"; +export { CreateQueryDTO, CreateBodyDTO } from "./req/create.dto"; +export { PurgeQueryDTO, PurgeBodyDTO } from "./req/purge.dto"; +export { GetByIdQueryDTO } from "./req/get-by-id.dto"; + +export { WorkScheduleDTO } from "./res/entity.dto"; +export { ListDTO } from "./res/list.dto"; + +export { FiltersDTO } from "./utils/filters.dto"; +export { SortDTO } from "./utils/sort.dto"; diff --git a/src/context/interface/dto/work-schedule/req/archive.dto.ts b/src/context/interface/dto/work-schedule/req/archive.dto.ts new file mode 100644 index 0000000..b35f248 --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/archive.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleArchiveBody" }) +export class ArchiveBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkScheduleArchiveQuery" }) +export class ArchiveQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/create.dto.ts b/src/context/interface/dto/work-schedule/req/create.dto.ts new file mode 100644 index 0000000..e981508 --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/create.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { CalendarApplication, SchedulePattern } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleCreateBody" }) +export class CreateBodyDTO { + @Expose() + @Validator.IsEnum(CalendarApplication) + @ApiProperty({ required: true }) + declare public calendarApplication: CalendarApplication; + + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true }) + declare public pattern: Entities.WorkSchedule.Pattern; + + @Expose() + @Validator.IsEnum(SchedulePattern) + @ApiProperty({ required: true }) + declare public patternType: SchedulePattern; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true }) + declare public name: string; +} + +@ApiSchema({ name: "WorkScheduleCreateQuery" }) +export class CreateQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/get-by-id.dto.ts b/src/context/interface/dto/work-schedule/req/get-by-id.dto.ts new file mode 100644 index 0000000..26e9512 --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/get-by-id.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { BaseReadQueryDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleGetByIdQuery" }) +export class GetByIdQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/get-list.dto.ts b/src/context/interface/dto/work-schedule/req/get-list.dto.ts new file mode 100644 index 0000000..f280f35 --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/get-list.dto.ts @@ -0,0 +1,46 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { IsNotEmptyObject } from "class-validator"; +import { Expose, Type } from "class-transformer"; + +import { BaseReadQueryDTO, PaginationDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +import { FiltersDTO } from "../utils/filters.dto"; +import { SortDTO } from "../utils/sort.dto"; + +@ApiSchema({ name: "WorkScheduleListBody" }) +export class GetListBodyDTO { + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => PaginationDTO) + @ApiProperty({ required: true, type: PaginationDTO }) + declare public pagination: PaginationDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => FiltersDTO) + @ApiProperty({ required: true, type: FiltersDTO }) + declare public filters: FiltersDTO; + + @Expose() + @IsNotEmptyObject() + @Validator.ValidateNested() + @Type(() => SortDTO) + @ApiProperty({ required: true, type: SortDTO }) + declare public sort: SortDTO; +} + +@ApiSchema({ name: "WorkScheduleListQuery" }) +export class GetListQueryDTO extends BaseReadQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/purge.dto.ts b/src/context/interface/dto/work-schedule/req/purge.dto.ts new file mode 100644 index 0000000..2895bfa --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/purge.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkSchedulePurgeBody" }) +export class PurgeBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkSchedulePurgeQuery" }) +export class PurgeQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/restore.dto.ts b/src/context/interface/dto/work-schedule/req/restore.dto.ts new file mode 100644 index 0000000..606cc4c --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/restore.dto.ts @@ -0,0 +1,30 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleRestoreBody" }) +export class RestoreBodyDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public reason: string; +} + +@ApiSchema({ name: "WorkScheduleRestoreQuery" }) +export class RestoreQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/req/revision.dto.ts b/src/context/interface/dto/work-schedule/req/revision.dto.ts new file mode 100644 index 0000000..cdf6250 --- /dev/null +++ b/src/context/interface/dto/work-schedule/req/revision.dto.ts @@ -0,0 +1,50 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; +import { CalendarApplication, SchedulePattern } from "~context/enums"; + +@ApiSchema({ name: "WorkScheduleCreateRevisionBody" }) +export class RevisionBodyDTO { + @Expose() + @Validator.IsOptional() + @Validator.IsString() + @ApiProperty({ required: false, type: String }) + declare public name?: string; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(SchedulePattern) + @ApiProperty({ required: false, enum: SchedulePattern }) + declare public patternType?: SchedulePattern; + + @Expose() + @Validator.IsOptional() + @Validator.IsObject() + @ApiProperty({ required: false, type: Object }) + declare public pattern?: Entities.WorkSchedule.Pattern; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(CalendarApplication) + @ApiProperty({ required: false, enum: CalendarApplication }) + declare public calendarApplication?: CalendarApplication; +} + +@ApiSchema({ name: "WorkScheduleCreateRevisionQuery" }) +export class CreateRevisionQueryDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public organization: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public realm: string; +} diff --git a/src/context/interface/dto/work-schedule/res/entity.dto.ts b/src/context/interface/dto/work-schedule/res/entity.dto.ts new file mode 100644 index 0000000..5a56d11 --- /dev/null +++ b/src/context/interface/dto/work-schedule/res/entity.dto.ts @@ -0,0 +1,64 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; + +import { CalendarApplication, SchedulePattern, RecordStatus } from "~context/enums"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkSchedule" }) +export class WorkScheduleDTO { + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public id: string; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public version: number; + + @Expose() + @Validator.IsDate() + @ApiProperty({ required: true, type: Date }) + declare public createdAt: Date; + + @Expose() + @Validator.IsOptional() + @Validator.IsDate() + @ApiProperty({ required: false, type: Date }) + declare public updatedAt?: Date; + + @Expose() + @Validator.IsEnum(CalendarApplication) + @ApiProperty({ required: true, type: Object }) + declare public calendarApplication: CalendarApplication; + + @Expose() + @Validator.IsEnum(SchedulePattern) + @ApiProperty({ required: true, type: Object }) + declare public patternType: SchedulePattern; + + @Expose() + @Validator.IsEnum(RecordStatus) + @ApiProperty({ required: true, type: Object }) + declare public status: RecordStatus; + + @Expose() + @Validator.IsObject() + @ApiProperty({ required: true, type: Object }) + declare public pattern: Entities.WorkSchedule.Pattern; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public revision: number; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public code: string; + + @Expose() + @Validator.IsString() + @ApiProperty({ required: true, type: String }) + declare public name: string; +} diff --git a/src/context/interface/dto/work-schedule/res/list.dto.ts b/src/context/interface/dto/work-schedule/res/list.dto.ts new file mode 100644 index 0000000..c36f156 --- /dev/null +++ b/src/context/interface/dto/work-schedule/res/list.dto.ts @@ -0,0 +1,47 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { Validator } from "~common/validator"; + +import { WorkScheduleDTO } from "./entity.dto"; + +@ApiSchema({ name: "WorkScheduleListMeta" }) +class WorkScheduleListMetaDTO { + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalElements: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public totalPages: number; + + @Expose() + @Validator.IsInt() + @Validator.IsIn([10, 25, 50, 100]) + @ApiProperty({ required: true, type: Number }) + declare public elementsPerPage: number; + + @Expose() + @Validator.IsInt() + @ApiProperty({ required: true, type: Number }) + declare public currentPage: number; +} + +@ApiSchema({ name: "WorkScheduleList" }) +export class ListDTO { + @Expose() + @Validator.IsArray() + @Validator.ValidateNested({ each: true }) + @Type(() => WorkScheduleDTO) + @ApiProperty({ required: true, type: [WorkScheduleDTO] }) + declare public data: WorkScheduleDTO[]; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => WorkScheduleListMetaDTO) + @ApiProperty({ required: false, type: WorkScheduleListMetaDTO }) + declare public meta?: WorkScheduleListMetaDTO; +} diff --git a/src/context/interface/dto/work-schedule/utils/filters.dto.ts b/src/context/interface/dto/work-schedule/utils/filters.dto.ts new file mode 100644 index 0000000..b6dc065 --- /dev/null +++ b/src/context/interface/dto/work-schedule/utils/filters.dto.ts @@ -0,0 +1,85 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { Expose, Type } from "class-transformer"; + +import { LinkFilterDTO, OrdinalFilterDTO, StringFilterDTO } from "~common/dto"; +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleFilters" }) +export class FiltersDTO implements Repositories.Mappers.WorkSchedule.Filters { + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public id?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public calendarApplication?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public patternType?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public status?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public code?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => StringFilterDTO) + @ApiProperty({ required: false, type: StringFilterDTO }) + public name?: StringFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public revision?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public version?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public createdAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => OrdinalFilterDTO) + @ApiProperty({ required: false, type: OrdinalFilterDTO }) + public updatedAt?: OrdinalFilterDTO; + + @Expose() + @Validator.IsOptional() + @Validator.ValidateNested() + @Type(() => LinkFilterDTO) + @ApiProperty({ required: false, type: LinkFilterDTO }) + public organization?: LinkFilterDTO; +} diff --git a/src/context/interface/dto/work-schedule/utils/sort.dto.ts b/src/context/interface/dto/work-schedule/utils/sort.dto.ts new file mode 100644 index 0000000..733b180 --- /dev/null +++ b/src/context/interface/dto/work-schedule/utils/sort.dto.ts @@ -0,0 +1,32 @@ +import { ApiProperty, ApiSchema } from "@nestjs/swagger"; +import { QueryOrder } from "@mikro-orm/postgresql"; +import { Expose } from "class-transformer"; + +import { Validator } from "~common/validator"; + +@ApiSchema({ name: "WorkScheduleSort" }) +export class SortDTO implements Repositories.Mappers.WorkSchedule.Sort { + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public createdAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public updatedAt?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public revision?: QueryOrder; + + @Expose() + @Validator.IsOptional() + @Validator.IsEnum(QueryOrder) + @ApiProperty({ required: false, enum: QueryOrder, enumName: "QueryOrder" }) + public version?: QueryOrder; +}