feat(integration-connector): 绑定参数映射与凭据 DB 加密落库模式
- 绑定新增 param_mapping_json:域参数→接口参数声明式映射(map_response 规范),空对象同名直通 - 凭据引用新增 db 维护模式:secret_ciphertext Fernet 加密落库,主密钥 INTEGRATION_CREDENTIAL_KEY 仅环境注入,与 env 引用模式并存 - 新增 credential_types 凭据形态注册表:代码注册各类型字段清单,UI 动态渲染与 API 组装校验的唯一事实来源 - 移除绑定 context_source_code 独立列,路由条件统一 context_selector_json - 管理端表单 Modal 重构为 Drawer,新增 JSON 编辑字段组件与页面级测试 - 迁移 rd1/re1 重挂当前唯一 head dd22ee33ff44,维持单 head 链 - settings 移除 IN_TRANSIT_TRANSFER_ERP_* 配置,外部端点/凭据移交连接器客户端实例管理
This commit is contained in:
1 parent
5df204fdea
commit
31591e663e
35 files changed
+4345
-750
No files matched your search
@@ -2,7 +2,9 @@
|
||||
|
||||
用途:Capability 强类型契约注册表(能力名称/输入输出 Schema/幂等语义/是否写)。
|
||||
依赖:app.core.errors、errors.py;纯代码,不依赖 DB。
|
||||
逻辑:能力必须由代码注册,不能由管理端动态定义;领域只调用已注册能力,未注册 fail-closed。
|
||||
逻辑:能力必须由代码注册,不能由管理端动态定义;各域契约声明在各域包的
|
||||
capabilities 模块(如 in_transit_transfer/capabilities.py),由应用组合根
|
||||
import 完成注册;领域只调用已注册能力,未注册 fail-closed。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,37 +14,6 @@ from dataclasses import dataclass
|
||||
from app.core.errors import ValidationError
|
||||
from app.services.integration_connector.errors import CapabilityNotFoundError
|
||||
|
||||
# 在途调拨能力输入/输出 Schema(JSON Schema 最小子集,供入参/出参校验)。
|
||||
_QUERY_INPUT_SCHEMA: dict = {
|
||||
"type": "object",
|
||||
"required": ["invoice_no", "from_warehouse", "to_warehouse", "quantity"],
|
||||
"properties": {
|
||||
"invoice_no": {"type": "string"},
|
||||
"from_warehouse": {"type": "string"},
|
||||
"to_warehouse": {"type": "string"},
|
||||
"quantity": {"type": "number"},
|
||||
},
|
||||
}
|
||||
_QUERY_OUTPUT_SCHEMA: dict = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"found": {"type": "boolean"},
|
||||
"quantity": {"type": ["number", "null"]},
|
||||
},
|
||||
}
|
||||
_WRITE_OUTPUT_SCHEMA: dict = {
|
||||
"type": "object",
|
||||
"required": ["status"],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["success", "business_failed", "technical_failed", "timeout", "result_unknown"],
|
||||
},
|
||||
"document_no": {"type": ["string", "null"]},
|
||||
"verified_posted": {"type": ["boolean", "null"]},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CapabilitySpec:
|
||||
@@ -56,7 +27,6 @@ class CapabilitySpec:
|
||||
|
||||
|
||||
_CAPABILITIES: dict[str, CapabilitySpec] = {}
|
||||
_LOADED = False
|
||||
|
||||
|
||||
def register_capability(spec: CapabilitySpec) -> CapabilitySpec:
|
||||
@@ -84,42 +54,6 @@ def list_capabilities() -> list[CapabilitySpec]:
|
||||
return sorted(_CAPABILITIES.values(), key=lambda s: s.name)
|
||||
|
||||
|
||||
def ensure_capabilities_loaded() -> None:
|
||||
"""惰性注册内置能力(幂等);由网关/API 在解析前调用。"""
|
||||
global _LOADED # noqa: PLW0603
|
||||
if _LOADED:
|
||||
return
|
||||
_LOADED = True
|
||||
_register_transfer_capabilities()
|
||||
|
||||
|
||||
def _register_transfer_capabilities() -> None:
|
||||
"""注册在途调拨域内置能力;领域代码只调这些能力,外部系统差异全在连接器层。"""
|
||||
register_capability(CapabilitySpec(
|
||||
name="in_transit_transfer.query_inventory",
|
||||
input_schema=_QUERY_INPUT_SCHEMA,
|
||||
output_schema=_QUERY_OUTPUT_SCHEMA,
|
||||
idempotency="none",
|
||||
write=False,
|
||||
))
|
||||
register_capability(CapabilitySpec(
|
||||
name="in_transit_transfer.create_transfer",
|
||||
input_schema=_QUERY_INPUT_SCHEMA,
|
||||
output_schema=_WRITE_OUTPUT_SCHEMA,
|
||||
idempotency="invoice",
|
||||
write=True,
|
||||
))
|
||||
register_capability(CapabilitySpec(
|
||||
name="in_transit_transfer.verify_duplicate",
|
||||
input_schema=_QUERY_INPUT_SCHEMA,
|
||||
output_schema=_WRITE_OUTPUT_SCHEMA,
|
||||
idempotency="invoice",
|
||||
write=False,
|
||||
))
|
||||
|
||||
|
||||
def reset_capability_registry_for_tests() -> None:
|
||||
"""单测隔离:清空注册表并重置加载标记。"""
|
||||
global _LOADED # noqa: PLW0603
|
||||
"""单测隔离:清空注册表(领域 capabilities 模块可重调其注册函数重建)。"""
|
||||
_CAPABILITIES.clear()
|
||||
_LOADED = False
|
||||
Reference in new issue
Block a user