ForcePilot/backend/package/yuxi/external_systems/integrations/notion/constants.py
Kris 74709ba2d3 feat: 完成外部系统限界上下文核心代码实现
新增六边形架构核心代码包,包含:
1. 协议适配器层:HTTP/SMTP/IMAP/SSH/GRPC等多协议适配器实现
2. 认证插件体系:基础认证、API密钥、HMAC等多类型认证插件
3. 执行编排框架:工具执行器、上下文构建、运行时治理组件
4. 用例端口与DTO:定义领域服务端口与数据传输对象
5. 厂商集成包框架:支持第三方系统集成扩展
6. 基础设施装配层:实现依赖注入与服务装配

所有代码遵循六边形架构设计原则,实现端口与适配器解耦,支持动态扩展与自动发现。
2026-06-20 22:12:42 +08:00

76 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Notion API 常量定义。
集中管理 Notion API 的版本、请求头、退避参数与类型枚举,
版本升级或参数调整时仅需修改本文件。
"""
from __future__ import annotations
from typing import Any
BASE_URL = "https://api.notion.com/v1"
NOTION_VERSION = "2022-06-28" # 当前稳定版本
# Notion 通用请求头(除 Authorization 外,由 executor 注入)
_NOTION_HEADERS: dict[str, str] = {
"Notion-Version": NOTION_VERSION,
"Accept": "application/json",
}
# 运行时工具执行的 429/5xx 退避:通过 retry_policy 配置
# executor 基于 tenacity 重试retry_status_codes 非空时按配置重试
_RUNTIME_RETRY_POLICY: dict[str, Any] = {
"max_attempts": 3,
"retry_delay": 1.0,
"retry_backoff": 2.0,
"retry_status_codes": [429, 502, 503, 504],
"retry_on_timeout": True,
"retry_on_connection_error": True,
}
# discover/preview/create 阶段 429 退避参数
_RETRY_MAX_ATTEMPTS = 5
_RETRY_BASE_DELAY = 1.0
# 数据库属性类型枚举(用于 property_mapper 校验)
PROPERTY_TYPES = frozenset(
{
"title",
"rich_text",
"number",
"select",
"multi_select",
"status",
"date",
"people",
"files",
"checkbox",
"url",
"email",
"phone_number",
"formula",
"relation",
"rollup",
"created_time",
"created_by",
"last_edited_time",
"last_edited_by",
}
)
# 文本类块类型枚举(用于 block_parser
TEXT_BLOCK_TYPES = frozenset(
{
"paragraph",
"heading_1",
"heading_2",
"heading_3",
"bulleted_list_item",
"numbered_list_item",
"to_do",
"toggle",
"quote",
"callout",
}
)