diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 7e75002..2cb7982 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -15,48 +15,6 @@ ] } }, - "/auth/v1/login": { - "get": { - "operationId": "AuthController_login", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/callback": { - "get": { - "operationId": "AuthController_loginCallback", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/me": { - "get": { - "operationId": "AuthController_getProfile", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Auth" - ] - } - }, "/notifications/summary": { "get": { "operationId": "NotificationsController_summary", @@ -85,169 +43,6 @@ ] } }, - "/pay-periods/current-and-all": { - "get": { - "operationId": "PayPeriodsController_getCurrentAndAll", - "parameters": [ - { - "name": "date", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, - "/pay-periods/date/{date}": { - "get": { - "operationId": "PayPeriodsController_findByDate", - "parameters": [ - { - "name": "date", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, - "/pay-periods/{year}/{periodNumber}": { - "get": { - "operationId": "PayPeriodsController_findOneByYear", - "parameters": [ - { - "name": "year", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - }, - { - "name": "periodNumber", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, - "/pay-periods/crew/pay-period-approval": { - "patch": { - "operationId": "PayPeriodsController_bulkApproval", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BulkCrewApprovalDto" - } - } - } - }, - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, - "/pay-periods/crew/{year}/{periodNumber}": { - "get": { - "operationId": "PayPeriodsController_getCrewOverview", - "parameters": [ - { - "name": "year", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - }, - { - "name": "periodNumber", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, - "/pay-periods/overview/{year}/{periodNumber}": { - "get": { - "operationId": "PayPeriodsController_getOverviewByYear", - "parameters": [ - { - "name": "year", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - }, - { - "name": "periodNumber", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PayPeriods" - ] - } - }, "/timesheets/{year}/{period_number}": { "get": { "operationId": "TimesheetController_getTimesheetByPayPeriod", @@ -293,39 +88,6 @@ ] } }, - "/preferences": { - "patch": { - "operationId": "PreferencesController_updatePreferences", - "parameters": [ - { - "name": "PreferencesDto", - "required": true, - "in": "body", - "schema": { - "$ref": "#/components/schemas/PreferencesDto" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "number" - } - } - } - }, - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Preferences" - ] - } - }, "/shift/create": { "post": { "operationId": "ShiftController_createBatch", @@ -581,6 +343,332 @@ "Expense" ] } + }, + "/pay-periods/current-and-all": { + "get": { + "operationId": "PayPeriodsController_getCurrentAndAll", + "parameters": [ + { + "name": "date", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/pay-periods/date/{date}": { + "get": { + "operationId": "PayPeriodsController_findByDate", + "parameters": [ + { + "name": "date", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/pay-periods/{year}/{periodNumber}": { + "get": { + "operationId": "PayPeriodsController_findOneByYear", + "parameters": [ + { + "name": "year", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + }, + { + "name": "periodNumber", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/pay-periods/crew/pay-period-approval": { + "patch": { + "operationId": "PayPeriodsController_bulkApproval", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BulkCrewApprovalDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/pay-periods/crew/{year}/{periodNumber}": { + "get": { + "operationId": "PayPeriodsController_getCrewOverview", + "parameters": [ + { + "name": "year", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + }, + { + "name": "periodNumber", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/pay-periods/overview/{year}/{periodNumber}": { + "get": { + "operationId": "PayPeriodsController_getOverviewByYear", + "parameters": [ + { + "name": "year", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + }, + { + "name": "periodNumber", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PayPeriods" + ] + } + }, + "/exports/csv": { + "get": { + "operationId": "CsvExportController_exportCsv", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "CsvExport" + ] + } + }, + "/auth/v1/login": { + "get": { + "operationId": "AuthController_login", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/callback": { + "get": { + "operationId": "AuthController_loginCallback", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/me": { + "get": { + "operationId": "AuthController_getProfile", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Auth" + ] + } + }, + "/employees/profile": { + "get": { + "operationId": "EmployeesController_findOneProfile", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Employees" + ] + } + }, + "/employees/employee-list": { + "get": { + "operationId": "EmployeesController_findListEmployees", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Employees" + ] + } + }, + "/employees": { + "patch": { + "operationId": "EmployeesController_updateOrArchiveOrRestore", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateEmployeeDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Employees" + ] + }, + "post": { + "operationId": "EmployeesController_create", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEmployeeDto" + } + } + } + }, + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "Employees" + ] + } + }, + "/preferences": { + "patch": { + "operationId": "PreferencesController_updatePreferences", + "parameters": [ + { + "name": "PreferencesDto", + "required": true, + "in": "body", + "schema": { + "$ref": "#/components/schemas/PreferencesDto" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "number" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Preferences" + ] + } } }, "info": { @@ -640,14 +728,6 @@ } }, "schemas": { - "BulkCrewApprovalDto": { - "type": "object", - "properties": {} - }, - "PreferencesDto": { - "type": "object", - "properties": {} - }, "SchedulePresetsDto": { "type": "object", "properties": {} @@ -659,6 +739,162 @@ "ExpenseDto": { "type": "object", "properties": {} + }, + "BulkCrewApprovalDto": { + "type": "object", + "properties": {} + }, + "UpdateEmployeeDto": { + "type": "object", + "properties": { + "id": { + "type": "number", + "example": 1, + "description": "Unique ID of an employee(primary-key, auto-incremented)" + }, + "user_id": { + "type": "string", + "example": "0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d", + "description": "UUID of the user linked to that employee" + }, + "first_name": { + "type": "string", + "example": "Frodo", + "description": "Employee`s first name" + }, + "last_name": { + "type": "string", + "example": "Baggins", + "description": "Employee`s last name" + }, + "email": { + "type": "string", + "example": "i_cant_do_this_sam@targointernet.com", + "description": "Employee`s email" + }, + "phone_number": { + "type": "string", + "example": "82538437464", + "description": "Employee`s phone number" + }, + "residence": { + "type": "string", + "example": "1 Bagshot Row, Hobbiton, The Shire, Middle-earth", + "description": "Employee`s residence" + }, + "external_payroll_id": { + "type": "number", + "example": 7464, + "description": "external ID for the pay system" + }, + "company_code": { + "type": "number", + "example": 335567447, + "description": "Employee`s company code" + }, + "job_title": { + "type": "string", + "example": "technicient", + "description": "employee`s job title" + }, + "first_work_day": { + "format": "date-time", + "type": "string", + "example": "23/09/3018", + "description": "New hire date or undefined" + }, + "last_work_day": { + "format": "date-time", + "type": "string", + "example": "25/03/3019", + "description": "Termination date (null to restore)" + }, + "supervisor_id": { + "type": "number", + "description": "Supervisor ID" + } + } + }, + "CreateEmployeeDto": { + "type": "object", + "properties": { + "id": { + "type": "number", + "example": 1, + "description": "Unique ID of an employee(primary-key, auto-incremented)" + }, + "user_id": { + "type": "string", + "example": "0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d", + "description": "UUID of the user linked to that employee" + }, + "first_name": { + "type": "string", + "example": "Frodo", + "description": "Employee`s first name" + }, + "last_name": { + "type": "string", + "example": "Baggins", + "description": "Employee`s last name" + }, + "email": { + "type": "string", + "example": "i_cant_do_this_sam@targointernet.com", + "description": "Employee`s email" + }, + "phone_number": { + "type": "string", + "example": "82538437464", + "description": "Employee`s phone number" + }, + "residence": { + "type": "string", + "example": "1 Bagshot Row, Hobbiton, The Shire, Middle-earth", + "description": "Employee`s residence" + }, + "external_payroll_id": { + "type": "number", + "example": 7464, + "description": "external ID for the pay system" + }, + "company_code": { + "type": "number", + "example": 335567447, + "description": "Employee`s company code" + }, + "job_title": { + "type": "string", + "example": "technicient", + "description": "employee`s job title" + }, + "first_work_day": { + "type": "string", + "example": "23/09/3018", + "description": "Employee`s first working day" + }, + "last_work_day": { + "type": "string", + "example": "25/03/3019", + "description": "Employee`s last working day" + } + }, + "required": [ + "id", + "user_id", + "first_name", + "last_name", + "email", + "phone_number", + "external_payroll_id", + "company_code", + "job_title", + "first_work_day" + ] + }, + "PreferencesDto": { + "type": "object", + "properties": {} } } } diff --git a/src/app.module.ts b/src/app.module.ts index dbe9dd9..717c52e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,36 +1,26 @@ import { BadRequestException, Module, ValidationPipe } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; -import { AuthenticationModule } from './identity-and-account/authentication/auth.module'; -// import { CsvExportModule } from './modules/exports/csv-exports.module'; -import { HealthModule } from './health/health.module'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; import { HealthController } from './health/health.controller'; import { NotificationsModule } from './modules/notifications/notifications.module'; -import { PreferencesModule } from './identity-and-account/preferences/preferences.module'; -import { PrismaModule } from './prisma/prisma.module'; -import { ScheduleModule } from '@nestjs/schedule'; -import { UsersModule } from './identity-and-account/users-management/users.module'; -import { ConfigModule } from '@nestjs/config'; +import { PrismaModule } from './prisma/prisma.module'; +import { ScheduleModule } from '@nestjs/schedule'; +import { ConfigModule } from '@nestjs/config'; import { APP_FILTER, APP_PIPE } from '@nestjs/core'; -import { HttpExceptionFilter } from './common/filters/http-exception.filter'; -import { ValidationError } from 'class-validator'; +import { HttpExceptionFilter } from './common/filters/http-exception.filter'; +import { ValidationError } from 'class-validator'; import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attendance.module'; -import { PayperiodsModule } from 'src/time-and-attendance/pay-period/pay-periods.module'; +import { IdentityAndAccountModule } from 'src/identity-and-account/identity-and-account.module'; @Module({ imports: [ - AuthenticationModule, - ConfigModule.forRoot({isGlobal: true}), - // CsvExportModule, - HealthModule, + ConfigModule.forRoot({ isGlobal: true }), + ScheduleModule.forRoot(), //cronjobs NotificationsModule, - PayperiodsModule, - PreferencesModule, PrismaModule, - ScheduleModule.forRoot(), //cronjobs TimeAndAttendanceModule, - UsersModule, - ], + IdentityAndAccountModule, + ], controllers: [AppController, HealthController], providers: [ AppService, @@ -44,9 +34,9 @@ import { PayperiodsModule } from 'src/time-and-attendance/pay-period/pay-periods whitelist: true, forbidNonWhitelisted: true, transform: true, - exceptionFactory: (errors: ValidationError[] = [])=> { - const messages = errors.flatMap((e)=> Object.values(e.constraints ?? {})); - return new BadRequestException({ + exceptionFactory: (errors: ValidationError[] = []) => { + const messages = errors.flatMap((e) => Object.values(e.constraints ?? {})); + return new BadRequestException({ statusCode: 400, error: 'Bad Request', message: messages.length ? messages : errors, @@ -56,4 +46,4 @@ import { PayperiodsModule } from 'src/time-and-attendance/pay-period/pay-periods }, ], }) -export class AppModule {} +export class AppModule { } diff --git a/src/identity-and-account/identity-and-account.module.ts b/src/identity-and-account/identity-and-account.module.ts new file mode 100644 index 0000000..979160d --- /dev/null +++ b/src/identity-and-account/identity-and-account.module.ts @@ -0,0 +1,35 @@ +import { Module } from "@nestjs/common"; +import { AuthModuleOptions } from "@nestjs/passport"; +import { AuthController } from "src/identity-and-account/authentication/controllers/auth.controller"; +import { AuthentikAuthService } from "src/identity-and-account/authentication/services/authentik-auth.service"; +import { EmployeesController } from "src/identity-and-account/employees/controllers/employees.controller"; +import { EmployeesModule } from "src/identity-and-account/employees/employees.module"; +import { EmployeesArchivalService } from "src/identity-and-account/employees/services/employees-archival.service"; +import { EmployeesService } from "src/identity-and-account/employees/services/employees.service"; +import { PreferencesController } from "src/identity-and-account/preferences/controllers/preferences.controller"; +import { PreferencesModule } from "src/identity-and-account/preferences/preferences.module"; +import { PreferencesService } from "src/identity-and-account/preferences/services/preferences.service"; +import { UsersService } from "src/identity-and-account/users-management/services/users.service"; +import { UsersModule } from "src/identity-and-account/users-management/users.module"; + +@Module({ + imports: [ + UsersModule, + EmployeesModule, + PreferencesModule, + AuthModuleOptions, + ], + controllers: [ + AuthController, + EmployeesController, + PreferencesController, + ], + providers: [ + AuthentikAuthService, + EmployeesArchivalService, + EmployeesService, + PreferencesService, + UsersService, + ], +}) +export class IdentityAndAccountModule { };