fix enum values
This commit is contained in:
parent
fd11af5ba3
commit
ebdbc6cf46
|
@ -1,6 +1,16 @@
|
|||
import { AutoMap } from '@automapper/classes';
|
||||
import { Domain } from '../../domain/dtos/domain.enum';
|
||||
|
||||
export class ConfigurationPresenter {
|
||||
@AutoMap()
|
||||
uuid: string;
|
||||
|
||||
@AutoMap()
|
||||
domain: Domain;
|
||||
|
||||
@AutoMap()
|
||||
key: string;
|
||||
|
||||
@AutoMap()
|
||||
value: string;
|
||||
}
|
||||
|
|
|
@ -16,15 +16,11 @@ message ConfigurationByUuid {
|
|||
|
||||
message Configuration {
|
||||
string uuid = 1;
|
||||
Domain domain = 2;
|
||||
string domain = 2;
|
||||
string key = 3;
|
||||
string value = 4;
|
||||
}
|
||||
|
||||
enum Domain {
|
||||
user = 0;
|
||||
}
|
||||
|
||||
message ConfigurationFilter {
|
||||
optional int32 page = 1;
|
||||
optional int32 perPage = 2;
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { DatabaseModule } from '../database/database.module';
|
||||
import { ConfigRepository } from '../database/src/domain/configuration.repository';
|
||||
import { ConfigurationController } from './adapters/primaries/configuration.controller';
|
||||
import { ConfigurationRepository } from './adapters/secondaries/configuration.repository';
|
||||
import { CreateConfigurationUseCase } from './domain/usecases/create-configuration.usecase';
|
||||
import { DeleteConfigurationUseCase } from './domain/usecases/delete-configuration.usecase';
|
||||
import { FindAllConfigurationsUseCase } from './domain/usecases/find-all-configurations.usecase';
|
||||
import { FindConfigurationByUuidUseCase } from './domain/usecases/find-configuration-by-uuid.usecase';
|
||||
import { UpdateConfigurationUseCase } from './domain/usecases/update-configuration.usecase';
|
||||
import { ConfigurationProfile } from './mappers/configuration.profile';
|
||||
|
||||
@Module({
|
||||
imports: [DatabaseModule, CqrsModule],
|
||||
exports: [],
|
||||
controllers: [ConfigurationController],
|
||||
providers: [ConfigurationProfile, ConfigRepository],
|
||||
providers: [
|
||||
ConfigurationProfile,
|
||||
ConfigurationRepository,
|
||||
FindAllConfigurationsUseCase,
|
||||
FindConfigurationByUuidUseCase,
|
||||
CreateConfigurationUseCase,
|
||||
UpdateConfigurationUseCase,
|
||||
DeleteConfigurationUseCase,
|
||||
],
|
||||
})
|
||||
export class ConfigurationModule {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AutoMap } from '@automapper/classes';
|
||||
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { Domain } from './domain.enum';
|
||||
|
||||
export class CreateConfigurationRequest {
|
||||
|
@ -8,7 +8,7 @@ export class CreateConfigurationRequest {
|
|||
@AutoMap()
|
||||
uuid?: string;
|
||||
|
||||
@IsString()
|
||||
@IsEnum(Domain)
|
||||
@IsNotEmpty()
|
||||
@AutoMap()
|
||||
domain: Domain;
|
||||
|
@ -18,7 +18,7 @@ export class CreateConfigurationRequest {
|
|||
@AutoMap()
|
||||
key: string;
|
||||
|
||||
@IsEmail()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@AutoMap()
|
||||
value: string;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export enum Domain {
|
||||
user = 'USER',
|
||||
USER = 'USER',
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AutoMap } from '@automapper/classes';
|
||||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { Domain } from './domain.enum';
|
||||
|
||||
export class UpdateConfigurationRequest {
|
||||
|
@ -8,7 +8,7 @@ export class UpdateConfigurationRequest {
|
|||
@AutoMap()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsEnum(Domain)
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
domain?: Domain;
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('ConfigurationRepository', () => {
|
|||
for (let i = 0; i < nbToCreate; i++) {
|
||||
await prismaService.configuration.create({
|
||||
data: {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: `key-${i}`,
|
||||
value: `key-${i}`,
|
||||
},
|
||||
|
@ -70,7 +70,7 @@ describe('ConfigurationRepository', () => {
|
|||
it('should return a configuration', async () => {
|
||||
const configurationToFind = await prismaService.configuration.create({
|
||||
data: {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
|
@ -94,14 +94,14 @@ describe('ConfigurationRepository', () => {
|
|||
it('should return a configuration according to its domain and key', async () => {
|
||||
const configurationToFind = await prismaService.configuration.create({
|
||||
data: {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
});
|
||||
|
||||
const configuration = await configurationRepository.findOne({
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
});
|
||||
|
||||
|
@ -110,7 +110,7 @@ describe('ConfigurationRepository', () => {
|
|||
|
||||
it('should return null with unknown domain and key', async () => {
|
||||
const configuration = await configurationRepository.findOne({
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
});
|
||||
expect(configuration).toBeNull();
|
||||
|
@ -122,7 +122,7 @@ describe('ConfigurationRepository', () => {
|
|||
const beforeCount = await prismaService.configuration.count();
|
||||
|
||||
const configurationToCreate: Configuration = new Configuration();
|
||||
configurationToCreate.domain = Domain.user;
|
||||
configurationToCreate.domain = Domain.USER;
|
||||
configurationToCreate.key = 'key1';
|
||||
configurationToCreate.value = 'value1';
|
||||
const configuration = await configurationRepository.create(
|
||||
|
@ -140,7 +140,7 @@ describe('ConfigurationRepository', () => {
|
|||
it('should update configuration key', async () => {
|
||||
const configurationToUpdate = await prismaService.configuration.create({
|
||||
data: {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
|
@ -174,7 +174,7 @@ describe('ConfigurationRepository', () => {
|
|||
it('should delete a configuration', async () => {
|
||||
const configurationToRemove = await prismaService.configuration.create({
|
||||
data: {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
|
|
|
@ -10,7 +10,7 @@ import { CreateConfigurationUseCase } from '../../domain/usecases/create-configu
|
|||
import { ConfigurationProfile } from '../../mappers/configuration.profile';
|
||||
|
||||
const newConfigurationRequest: CreateConfigurationRequest = {
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'minAge',
|
||||
value: '16',
|
||||
};
|
||||
|
|
|
@ -7,19 +7,19 @@ import { DeleteConfigurationUseCase } from '../../domain/usecases/delete-configu
|
|||
const mockConfigurations = [
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key2',
|
||||
value: 'value2',
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key3',
|
||||
value: 'value3',
|
||||
},
|
||||
|
|
|
@ -16,19 +16,19 @@ const findAllConfigurationsQuery: FindAllConfigurationsQuery =
|
|||
const mockConfigurations = [
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key2',
|
||||
value: 'value2',
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key3',
|
||||
value: 'value3',
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@ import { FindConfigurationByUuidQuery } from '../../queries/find-configuration-b
|
|||
|
||||
const mockConfiguration = {
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
domain: Domain.user,
|
||||
domain: Domain.USER,
|
||||
key: 'key1',
|
||||
value: 'value1',
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue