diff --git a/generators/spring-boot/cleanup.ts b/generators/spring-boot/cleanup.ts index 846cdcf7b078..c6be4ab1f5cb 100644 --- a/generators/spring-boot/cleanup.ts +++ b/generators/spring-boot/cleanup.ts @@ -179,12 +179,12 @@ export default asWritingTask(function cleanupTask(this, taskParam) { } if ( application.databaseTypeSql || - (application as any).cacheProviderRedis || + application.cacheProviderRedis || application.databaseTypeMongodb || application.databaseTypeCassandra || - (application as any).searchEngineElasticsearch || + application.searchEngineElasticsearch || application.databaseTypeCouchbase || - (application as any).searchEngineCouchbase || + application.searchEngineCouchbase || application.databaseTypeNeo4j ) { // The condition is too complated, delete and recreate. diff --git a/generators/spring-boot/command.ts b/generators/spring-boot/command.ts index c57815e64bc7..bd9d1645307b 100644 --- a/generators/spring-boot/command.ts +++ b/generators/spring-boot/command.ts @@ -20,10 +20,12 @@ import chalk from 'chalk'; import type { JHipsterCommandDefinition } from '../../lib/command/index.js'; import { GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.js'; import { createBase64Secret, createSecret } from '../base/support/secret.js'; -import { applicationTypes, authenticationTypes } from '../../lib/jhipster/index.js'; +import { applicationTypes, authenticationTypes, databaseTypes, serviceDiscoveryTypes } from '../../lib/jhipster/index.js'; const { OAUTH2, SESSION, JWT } = authenticationTypes; +const { CONSUL, EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes; const { GATEWAY, MICROSERVICE } = applicationTypes; +const { SQL, NO: NO_DATABASE, MONGODB, COUCHBASE, CASSANDRA, NEO4J } = databaseTypes; const command = { options: { @@ -73,12 +75,12 @@ const command = { when: () => ['gateway', 'microservice'].includes(gen.jhipsterConfigWithDefaults.applicationType), type: 'list', message: 'Which service discovery server do you want to use?', - default: 'consul', + default: CONSUL, }), choices: [ - { value: 'consul', name: 'Consul (recommended)' }, - { value: 'eureka', name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)' }, - { value: 'no', name: 'No service discovery' }, + { value: CONSUL, name: 'Consul (recommended)' }, + { value: EUREKA, name: 'JHipster Registry (legacy, uses Eureka, provides Spring Cloud Config support)' }, + { value: NO_SERVICE_DISCOVERY, name: 'No service discovery' }, ], scope: 'storage', }, @@ -98,9 +100,9 @@ const command = { default: () => gen.jhipsterConfigWithDefaults.authenticationType, }), choices: [ - { value: 'jwt', name: 'JWT authentication (stateless, with a token)' }, - { value: 'oauth2', name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)' }, - { value: 'session', name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)' }, + { value: JWT, name: 'JWT authentication (stateless, with a token)' }, + { value: OAUTH2, name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)' }, + { value: SESSION, name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)' }, ], configure: gen => { const { jwtSecretKey, rememberMeKey, authenticationType, applicationType } = gen.jhipsterConfigWithDefaults; @@ -177,7 +179,7 @@ const command = { type: String, hide: true, }, - choices: ['sql', 'mongodb', 'couchbase', 'cassandra', 'neo4j', 'no'], + choices: [SQL, MONGODB, COUCHBASE, CASSANDRA, NEO4J, NO_DATABASE], scope: 'storage', }, }, diff --git a/generators/spring-boot/generator.ts b/generators/spring-boot/generator.ts index 4334d43537e7..e22a2a5a61c3 100644 --- a/generators/spring-boot/generator.ts +++ b/generators/spring-boot/generator.ts @@ -430,14 +430,13 @@ public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) { } }, prepareFilters({ application, entity }) { - (entity as any).entityJavaFilterableProperties = [ - ...entity.fields.filter(field => field.filterableField), - ...entity.relationships.filter(rel => !application.reactive || (rel.persistableRelationship && !rel.collection)), - ]; - (entity as any).entityJavaCustomFilters = sortedUniqBy( - entity.fields.map(field => field.propertyJavaCustomFilter).filter(Boolean), - 'type', - ); + mutateData(entity, { + entityJavaFilterableProperties: [ + ...entity.fields.filter(field => field.filterableField), + ...entity.relationships.filter(rel => !application.reactive || (rel.persistableRelationship && !rel.collection)), + ], + entityJavaCustomFilters: sortedUniqBy(entity.fields.map(field => field.propertyJavaCustomFilter).filter(Boolean), 'type'), + }); }, }); } @@ -487,9 +486,14 @@ public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) { get postWriting() { return this.asPostWritingTaskGroup({ addJHipsterBomDependencies({ application, source }) { - const { applicationTypeGateway, applicationTypeMicroservice, javaDependencies, jhipsterDependenciesVersion, messageBrokerAny } = - application; - const { serviceDiscoveryAny } = application as any; + const { + applicationTypeGateway, + applicationTypeMicroservice, + javaDependencies, + jhipsterDependenciesVersion, + messageBrokerAny, + serviceDiscoveryAny, + } = application; source.addJavaDefinitions?.( { diff --git a/generators/spring-boot/prompts.ts b/generators/spring-boot/prompts.ts index 26fc96f92477..a7d80fa3e03a 100644 --- a/generators/spring-boot/prompts.ts +++ b/generators/spring-boot/prompts.ts @@ -104,7 +104,7 @@ export async function askForServerSideOpts(this: CoreGenerator, { control }) { }); } opts.push({ - value: 'couchbase', + value: COUCHBASE, name: '[BETA] Couchbase', }); opts.push({