# ============================================================================
# UnionFlow Server — Configuration commune (tous profils)
# Chargée en premier, les fichiers application-{profil}.properties surchargent
# ============================================================================

quarkus.application.name=unionflow-server
quarkus.application.version=1.0.0

# Configuration HTTP
quarkus.http.port=8085
quarkus.http.host=0.0.0.0
quarkus.http.limits.max-body-size=10M
quarkus.http.limits.max-header-size=16K

# Configuration Datasource — db-kind est une propriété build-time (commune à tous profils)
# Les valeurs réelles sont surchargées par application-dev.properties et application-prod.properties
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=${DB_USERNAME:unionflow}
quarkus.datasource.password=${DB_PASSWORD:changeme}
quarkus.datasource.jdbc.url=${DB_URL:jdbc:postgresql://localhost:5432/unionflow}

# Configuration CORS
quarkus.http.cors=true
quarkus.http.cors.methods=GET,POST,PUT,DELETE,OPTIONS
quarkus.http.cors.headers=Content-Type,Authorization

# Chemins publics
quarkus.http.auth.permission.public.paths=/health,/q/*,/favicon.ico,/auth/callback,/auth/*
quarkus.http.auth.permission.public.policy=permit

# Configuration Hibernate — base commune
quarkus.hibernate-orm.database.generation=update
quarkus.hibernate-orm.log.sql=false
quarkus.hibernate-orm.jdbc.timezone=UTC
quarkus.hibernate-orm.metrics.enabled=false

# Configuration Flyway — base commune
quarkus.flyway.migrate-at-start=true
quarkus.flyway.baseline-on-migrate=true
quarkus.flyway.baseline-version=0

# Configuration Keycloak OIDC — base commune
quarkus.oidc.application-type=service
quarkus.oidc.roles.role-claim-path=realm_access/roles

# Keycloak Policy Enforcer (PERMISSIVE — sécurité gérée par @RolesAllowed)
quarkus.keycloak.policy-enforcer.enable=false
quarkus.keycloak.policy-enforcer.lazy-load-paths=true
quarkus.keycloak.policy-enforcer.enforcement-mode=PERMISSIVE

# Configuration OpenAPI
quarkus.smallrye-openapi.info-title=UnionFlow Server API
quarkus.smallrye-openapi.info-version=1.0.0
quarkus.smallrye-openapi.info-description=API REST pour la gestion d'union avec authentification Keycloak
quarkus.smallrye-openapi.security-scheme=oidc
quarkus.smallrye-openapi.security-scheme-name=Keycloak
quarkus.smallrye-openapi.security-scheme-description=Authentification Bearer JWT via Keycloak

# Swagger UI
quarkus.swagger-ui.always-include=true
quarkus.swagger-ui.path=/swagger-ui
quarkus.swagger-ui.doc-expansion=list
quarkus.swagger-ui.filter=true
quarkus.swagger-ui.deep-linking=true
quarkus.swagger-ui.operations-sorter=alpha
quarkus.swagger-ui.tags-sorter=alpha

# Health
quarkus.smallrye-health.root-path=/health

# Logging — base commune
quarkus.log.console.enable=true
quarkus.log.console.level=INFO
quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{2.}] (%t) %s%e%n
quarkus.log.category."dev.lions.unionflow".level=INFO
quarkus.log.category."org.hibernate".level=WARN
quarkus.log.category."io.quarkus".level=INFO

# Arc / MapStruct
quarkus.arc.remove-unused-beans=false
quarkus.arc.unremovable-types=dev.lions.unionflow.server.mapper.**

# Jandex
quarkus.index-dependency.unionflow-server-api.group-id=dev.lions.unionflow
quarkus.index-dependency.unionflow-server-api.artifact-id=unionflow-server-api

# REST Client lions-user-manager
quarkus.rest-client.lions-user-manager-api.url=${LIONS_USER_MANAGER_URL:http://localhost:8081}

# Wave Money — Checkout API (https://docs.wave.com/checkout)
# Test : WAVE_API_KEY vide ou absent + wave.mock.enabled=true pour mocker Wave
wave.api.key=${WAVE_API_KEY: }
wave.api.secret=${WAVE_API_SECRET: }
wave.api.base.url=${WAVE_API_BASE_URL:https://api.wave.com/v1}
wave.environment=${WAVE_ENVIRONMENT:sandbox}
wave.webhook.secret=${WAVE_WEBHOOK_SECRET: }
# URLs de redirection (https en prod). Défaut dev: http://localhost:8080
wave.redirect.base.url=${WAVE_REDIRECT_BASE_URL:http://localhost:8080}
# Mock Wave (tests) : true = pas d'appel API, validation simulée. Si api.key vide, mock auto.
wave.mock.enabled=${WAVE_MOCK_ENABLED:false}
# Schéma deep link pour le retour vers l'app mobile (ex: unionflow)
wave.deep.link.scheme=${WAVE_DEEP_LINK_SCHEME:unionflow}

# ============================================================================
# Kafka Event Streaming Configuration
# ============================================================================

# Kafka Bootstrap Servers
kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}

# Producer Channels (Outgoing)
mp.messaging.outgoing.finance-approvals-out.connector=smallrye-kafka
mp.messaging.outgoing.finance-approvals-out.topic=unionflow.finance.approvals
mp.messaging.outgoing.finance-approvals-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.finance-approvals-out.key.serializer=org.apache.kafka.common.serialization.StringSerializer

mp.messaging.outgoing.dashboard-stats-out.connector=smallrye-kafka
mp.messaging.outgoing.dashboard-stats-out.topic=unionflow.dashboard.stats
mp.messaging.outgoing.dashboard-stats-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.dashboard-stats-out.key.serializer=org.apache.kafka.common.serialization.StringSerializer

mp.messaging.outgoing.notifications-out.connector=smallrye-kafka
mp.messaging.outgoing.notifications-out.topic=unionflow.notifications.user
mp.messaging.outgoing.notifications-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.notifications-out.key.serializer=org.apache.kafka.common.serialization.StringSerializer

mp.messaging.outgoing.members-events-out.connector=smallrye-kafka
mp.messaging.outgoing.members-events-out.topic=unionflow.members.events
mp.messaging.outgoing.members-events-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.members-events-out.key.serializer=org.apache.kafka.common.serialization.StringSerializer

mp.messaging.outgoing.contributions-events-out.connector=smallrye-kafka
mp.messaging.outgoing.contributions-events-out.topic=unionflow.contributions.events
mp.messaging.outgoing.contributions-events-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
mp.messaging.outgoing.contributions-events-out.key.serializer=org.apache.kafka.common.serialization.StringSerializer

# Consumer Channels (Incoming)
mp.messaging.incoming.finance-approvals-in.connector=smallrye-kafka
mp.messaging.incoming.finance-approvals-in.topic=unionflow.finance.approvals
mp.messaging.incoming.finance-approvals-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.finance-approvals-in.key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.finance-approvals-in.group.id=unionflow-websocket-server

mp.messaging.incoming.dashboard-stats-in.connector=smallrye-kafka
mp.messaging.incoming.dashboard-stats-in.topic=unionflow.dashboard.stats
mp.messaging.incoming.dashboard-stats-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.dashboard-stats-in.key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.dashboard-stats-in.group.id=unionflow-websocket-server

mp.messaging.incoming.notifications-in.connector=smallrye-kafka
mp.messaging.incoming.notifications-in.topic=unionflow.notifications.user
mp.messaging.incoming.notifications-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.notifications-in.key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.notifications-in.group.id=unionflow-websocket-server

mp.messaging.incoming.members-events-in.connector=smallrye-kafka
mp.messaging.incoming.members-events-in.topic=unionflow.members.events
mp.messaging.incoming.members-events-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.members-events-in.key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.members-events-in.group.id=unionflow-websocket-server

mp.messaging.incoming.contributions-events-in.connector=smallrye-kafka
mp.messaging.incoming.contributions-events-in.topic=unionflow.contributions.events
mp.messaging.incoming.contributions-events-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.contributions-events-in.key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.contributions-events-in.group.id=unionflow-websocket-server
