# Copyright (c) 2025, JINGROW and contributors
# For license information, please see license.txt

"""
Jingrow 框架核心钩子配置

此文件定义了框架的所有钩子扩展点，应用可以通过 hooks.py 注册自己的处理器。
"""

app_name = "jingrow"
app_title = "Jingrow"
app_publisher = "Jingrow"
app_description = "Jingrow Framework"
app_email = "support@jingrow.com"
app_license = "mit"

# ========== 应用生命周期钩子 ==========
after_install = ""
after_uninstall = ""

# ========== 请求钩子 ==========
before_request = [
    # 请求前处理，如认证、限流等
]

after_request = [
    # 请求后处理，如日志、性能统计等
]

# ========== 后台任务钩子 ==========
before_job = [
    # 后台任务执行前
]

after_job = [
    # 后台任务执行后
]

# ========== 页面生命周期钩子 (pg_events) ==========
# 格式: {pagetype: {event_name: [handler_path, ...]}}
# 或: {pagetype: {event_name: handler_path}}
# 或: {"*": {event_name: [handler_path, ...]}}  # 所有页面类型

pg_events = {
    "*": {
        # 所有页面类型的通用钩子
        "before_insert": [
            # 页面插入前
        ],
        "after_insert": [
            # 页面插入后
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
        "on_update": [
            # 页面更新时
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
        "on_submit": [
            # 页面提交时
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
        "on_change": [
            # 页面字段变化时
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
        "on_trash": [
            # 页面删除时
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
        "on_cancel": [
            # 页面取消时
            "jingrow.ai.pagetype.local_ai_agent.run_agent",
        ],
    },
    # 示例：特定页面类型的钩子
    # "User": {
    #     "after_insert": "myapp.hooks.send_welcome_email",
    #     "on_update": [
    #         "myapp.hooks.log_user_changes",
    #         "myapp.hooks.sync_to_external_system",
    #     ],
    # },
}

# ========== 定时任务钩子 (scheduler_events) ==========
scheduler_events = {
    "cron": {
        # Cron 表达式钩子
        # "0/15 * * * *": [  # 每15分钟
        #     "jingrow.utils.cleanup.cleanup_temp_files",
        # ],
    },
    "hourly": [
        # 每小时执行
    ],
    "daily": [
        # 每天执行
    ],
    "weekly": [
        # 每周执行
    ],
    "monthly": [
        # 每月执行
    ],
}

# Jinja 过滤器和方法
jinja = {
    "methods": [],
    "filters": [],
}

# ========== 其他钩子 ==========
