import { LOGIN_REGEX, MAIN_DIR, TEST_DIR } from "../generator-constants.js";
export const mutateApplication = {
    __override__: false,
    srcMain: MAIN_DIR,
    srcTest: TEST_DIR,
    loginRegex: LOGIN_REGEX,
    authenticationTypeSession: data => data.authenticationType === 'session',
    authenticationTypeJwt: data => data.authenticationType === 'jwt',
    authenticationTypeOauth2: data => data.authenticationType === 'oauth2',
    authenticationUsesCsrf: ({ authenticationType }) => ['oauth2', 'session'].includes(authenticationType),
    endpointPrefix: ({ applicationType, lowercaseBaseName }) => (applicationType === 'microservice' ? `services/${lowercaseBaseName}` : ''),
    devServerPort: (_, { delayMarker }) => delayMarker ?? 9060,
    serverPort: ({ applicationTypeMicroservice }) => (applicationTypeMicroservice ? 8081 : 8080),
    gatewayServerPort: (ctx, { undefinedMarker }) => (ctx.microfrontend && ctx.applicationTypeMicroservice ? 8080 : undefinedMarker),
    generateInMemoryUserCredentials: data => data.generateAuthenticationApi && data.skipUserManagement && !data.authenticationTypeUsesRemoteAuthorization,
    defaultAdminUsername: 'admin',
    defaultAdminPassword: 'admin',
    defaultAdminRoles: ['ADMIN', 'USER'],
    defaultUserUsername: data => (data.generateInMemoryUserCredentials ? data.defaultAdminUsername : 'user'),
    defaultUserPassword: data => (data.generateInMemoryUserCredentials ? data.defaultAdminPassword : 'user'),
    defaultUserRoles: data => (data.generateInMemoryUserCredentials ? data.defaultAdminRoles : ['USER']),
};
