syntax = "proto3";
package kratos.api;

option go_package = "kra/internal/conf;conf";

import "google/protobuf/duration.proto";

message Bootstrap {
  Server server = 1;
  JWT jwt = 2;
  System system = 3;
  Captcha captcha = 4;
  Mysql mysql = 5;
  Pgsql pgsql = 6;
  Sqlite sqlite = 7;
  Redis redis = 8;
  Local local = 9;
  Qiniu qiniu = 10;
  Minio minio = 11;
  AliyunOss aliyun_oss = 12;
  TencentCos tencent_cos = 13;
  AwsS3 aws_s3 = 14;
  CloudflareR2 cloudflare_r2 = 15;
  HuaweiObs huawei_obs = 16;
  Email email = 17;
  Excel excel = 18;
  Cors cors = 19;
  Zap zap = 20;
  MCP mcp = 21;
  Autocode autocode = 22;
  Mssql mssql = 23;
  Oracle oracle = 24;
  Mongo mongo = 25;
  repeated SpecializedDB db_list = 26;
  repeated Redis redis_list = 27;
  repeated DiskList disk_list = 28;
}

message Server {
  message HTTP {
    string network = 1;
    string addr = 2;
    google.protobuf.Duration timeout = 3;
  }
  message GRPC {
    string network = 1;
    string addr = 2;
    google.protobuf.Duration timeout = 3;
  }
  HTTP http = 1;
  GRPC grpc = 2;
}

message JWT {
  string signing_key = 1;
  string expires_time = 2;
  string buffer_time = 3;
  string issuer = 4;
}

message System {
  string env = 1;
  string db_type = 2;
  string oss_type = 3;
  bool use_redis = 4;
  bool use_multipoint = 5;
  int32 iplimit_count = 6;
  int32 iplimit_time = 7;
  string router_prefix = 8;
  bool use_strict_auth = 9;
  int32 addr = 10;
  bool use_mongo = 11;
  bool disable_auto_migrate = 12;
}

message Captcha {
  int32 key_long = 1;
  int32 img_width = 2;
  int32 img_height = 3;
  int32 open_captcha = 4;
  int32 open_captcha_timeout = 5;
}

// GeneralDB contains common database configuration fields
message GeneralDB {
  string prefix = 1;
  string port = 2;
  string config = 3;
  string db_name = 4;
  string username = 5;
  string password = 6;
  string path = 7;
  string engine = 8;
  string log_mode = 9;
  int32 max_idle_conns = 10;
  int32 max_open_conns = 11;
  bool singular = 12;
  bool log_zap = 13;
}

message Mysql {
  string prefix = 1;
  string path = 2;
  string port = 3;
  string config = 4;
  string db_name = 5;
  string username = 6;
  string password = 7;
  string engine = 8;
  int32 max_idle_conns = 9;
  int32 max_open_conns = 10;
  string log_mode = 11;
  bool log_zap = 12;
  bool singular = 13;
}

message Pgsql {
  string prefix = 1;
  string path = 2;
  string port = 3;
  string config = 4;
  string db_name = 5;
  string username = 6;
  string password = 7;
  string engine = 8;
  int32 max_idle_conns = 9;
  int32 max_open_conns = 10;
  string log_mode = 11;
  bool log_zap = 12;
  bool singular = 13;
}

message Sqlite {
  string prefix = 1;
  string path = 2;
  string db_name = 3;
  string engine = 4;
  int32 max_idle_conns = 5;
  int32 max_open_conns = 6;
  string log_mode = 7;
  bool log_zap = 8;
  bool singular = 9;
}

message Mssql {
  string prefix = 1;
  string path = 2;
  string port = 3;
  string config = 4;
  string db_name = 5;
  string username = 6;
  string password = 7;
  string engine = 8;
  int32 max_idle_conns = 9;
  int32 max_open_conns = 10;
  string log_mode = 11;
  bool log_zap = 12;
  bool singular = 13;
}

message Oracle {
  string prefix = 1;
  string path = 2;
  string port = 3;
  string config = 4;
  string db_name = 5;
  string username = 6;
  string password = 7;
  string engine = 8;
  int32 max_idle_conns = 9;
  int32 max_open_conns = 10;
  string log_mode = 11;
  bool log_zap = 12;
  bool singular = 13;
}

// SpecializedDB for db-list configuration
message SpecializedDB {
  string type = 1;
  string alias_name = 2;
  string prefix = 3;
  string port = 4;
  string config = 5;
  string db_name = 6;
  string username = 7;
  string password = 8;
  string path = 9;
  string engine = 10;
  string log_mode = 11;
  int32 max_idle_conns = 12;
  int32 max_open_conns = 13;
  bool singular = 14;
  bool log_zap = 15;
  bool disable = 16;
}

message Redis {
  string name = 1;
  bool use_cluster = 2;
  string addr = 3;
  string password = 4;
  int32 db = 5;
  repeated string cluster_addrs = 6;
}

message Mongo {
  string coll = 1;
  string options = 2;
  string database = 3;
  string username = 4;
  string password = 5;
  string auth_source = 6;
  uint64 min_pool_size = 7;
  uint64 max_pool_size = 8;
  int64 socket_timeout_ms = 9;
  int64 connect_timeout_ms = 10;
  bool is_zap = 11;
  repeated MongoHost hosts = 12;
}

message MongoHost {
  string host = 1;
  string port = 2;
}

message Local {
  string path = 1;
  string store_path = 2;
}

message Qiniu {
  string zone = 1;
  string bucket = 2;
  string img_path = 3;
  bool use_https = 4;
  string access_key = 5;
  string secret_key = 6;
  bool use_cdn_domains = 7;
}

message Minio {
  string endpoint = 1;
  string access_key_id = 2;
  string access_key_secret = 3;
  string bucket_name = 4;
  bool use_ssl = 5;
  string base_path = 6;
  string bucket_url = 7;
}

message AliyunOss {
  string endpoint = 1;
  string access_key_id = 2;
  string access_key_secret = 3;
  string bucket_name = 4;
  string bucket_url = 5;
  string base_path = 6;
}

message TencentCos {
  string bucket = 1;
  string region = 2;
  string secret_id = 3;
  string secret_key = 4;
  string base_url = 5;
  string path_prefix = 6;
}

message AwsS3 {
  string bucket = 1;
  string region = 2;
  string endpoint = 3;
  bool s3_force_path_style = 4;
  bool disable_ssl = 5;
  string secret_id = 6;
  string secret_key = 7;
  string base_url = 8;
  string path_prefix = 9;
}

message CloudflareR2 {
  string bucket = 1;
  string base_url = 2;
  string path = 3;
  string account_id = 4;
  string access_key_id = 5;
  string secret_access_key = 6;
}

message HuaweiObs {
  string path = 1;
  string bucket = 2;
  string endpoint = 3;
  string access_key = 4;
  string secret_key = 5;
}

message Email {
  string to = 1;
  int32 port = 2;
  string from = 3;
  string host = 4;
  bool is_ssl = 5;
  string secret = 6;
  string nickname = 7;
  bool is_login_auth = 8;
}

message Excel {
  string dir = 1;
}

message Cors {
  string mode = 1;
  repeated CorsWhitelist whitelist = 2;
}

message CorsWhitelist {
  string allow_origin = 1;
  string allow_headers = 2;
  string allow_methods = 3;
  string expose_headers = 4;
  bool allow_credentials = 5;
}

message Zap {
  string level = 1;
  string format = 2;
  string prefix = 3;
  string director = 4;
  bool show_line = 5;
  string encode_level = 6;
  string stacktrace_key = 7;
  bool log_in_console = 8;
  int32 retention_day = 9;
}

message Autocode {
  string web = 1;
  string root = 2;
  string server = 3;
  string module = 4;
  string ai_path = 5;
}

message MCP {
  string name = 1;
  string version = 2;
  string sse_path = 3;
  string message_path = 4;
  string url_prefix = 5;
  int32 addr = 6;
  bool separate = 7;
  bool enabled = 8;
}

message DiskList {
  string mount_point = 1;
}
