package com.malk.apigw.caller;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * {@code com.caller.registry.*} + {@code com.actions.enabled} 配置绑定
 */
@Data
@Component
@ConfigurationProperties(prefix = "com")
public class CallerRegistryProperties {

    /** 调用方注册表配置 */
    private Registry caller = new Registry();

    /** 全局 action 白名单（vendor.action） */
    private Actions actions = new Actions();

    @Data
    public static class Registry {
        private String formUuid;
        private long ttlSeconds = 300;
        private Field field = new Field();
    }

    @Data
    public static class Field {
        private String callerId = "textField_callerId";
        private String callerSecret = "textField_callerSecret";
        private String callerName = "textField_callerName";
        private String allowedActions = "textareaField_allowedActions";
        private String rateLimit = "numberField_rateLimit";
        private String expireAt = "dateField_expireAt";
        private String enabled = "radioField_enabled";
    }

    @Data
    public static class Actions {
        /** 全局开放的 action 清单（需与 ActionRegistry 已注册的 key 相同才生效） */
        private List<String> enabled;
    }
}
