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:
hugo committed 2026-09-23 00:44:56 +08:00
1 parent 5df204fdea
commit 31591e663e
35 files changed
+4345 -750

No files matched your search

@@ -0,0 +1,45 @@
"""
backend/migrations/versions/rd1e2f3a4b5c_integration_connector_param_mapping_and_db_credentials.py
用途:集成连接器两项增强——绑定增加参数映射列、凭据引用增加密文列(db 维护模式)。
依赖:Alembic revision dd22ee33ff44(当前唯一 head);integration_bindings / integration_credential_references 已存在。
逻辑:param_mapping_json 承载域参数→接口参数的声明式映射(空对象=同名直通);
secret_ciphertext 承载凭据 JSON 的 Fernet 密文(主密钥 INTEGRATION_CREDENTIAL_KEY
环境注入),与既有 env 引用模式并存(secret_provider 区分)。
Revision ID: rd1e2f3a4b5c
Revises: dd22ee33ff44
Create Date: 2026-09-21 19:00:00.000000
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision = "rd1e2f3a4b5c"
down_revision = "dd22ee33ff44"
branch_labels = None
depends_on = None
# 与 context_selector_json 同类型约定:PostgreSQL 用 JSONB,SQLite/测试用 JSON。
PARAM_MAPPING_JSON = sa.JSON().with_variant(postgresql.JSONB(), 'postgresql')
def upgrade() -> None:
"""绑定加参数映射列;凭据引用加密文列(可空,兼容既有 env 模式行)。"""
op.add_column(
'integration_bindings',
sa.Column('param_mapping_json', PARAM_MAPPING_JSON, nullable=False, server_default=sa.text("'{}'")),
)
op.add_column(
'integration_credential_references',
sa.Column('secret_ciphertext', sa.Text(), nullable=True),
)
def downgrade() -> None:
"""删除两列(param_mapping/密文均可由配置与凭据重新维护,无衍生数据)。"""
op.drop_column('integration_credential_references', 'secret_ciphertext')
op.drop_column('integration_bindings', 'param_mapping_json')
@@ -0,0 +1,31 @@
"""drop integration binding context_source_code
Revision ID: re1f3a4b5c6d
Revises: rd1e2f3a4b5c
Create Date: 2026-09-22 10:00:00.000000
用途:删除 IntegrationBinding.context_source_code 独立列(过度设计一刀切)。
依赖:ix1a2b3c4d5e 加列;rd1e2f3a4b5c 为当前 head。
逻辑:context_source_code 只是 context_selector_json 中 source_code 键的快捷列,
与高级配置(context_selector_json)机制重复;按路由条件统一走
context_selector_json 的约定删列,不设兼容层(框架未上线,无存量数据顾虑)。
"""
from alembic import op
import sqlalchemy as sa
revision = 're1f3a4b5c6d'
down_revision = 'rd1e2f3a4b5c'
branch_labels = None
depends_on = None
def upgrade() -> None:
"""删除绑定表的 context_source_code 快捷列(路由条件统一由 context_selector_json 表达)。"""
op.drop_column('integration_bindings', 'context_source_code')
def downgrade() -> None:
"""回滚:恢复 context_source_code 列(nullable,与拆列迁移 ix1a2b3c4d5e 时的定义一致)。"""
op.add_column('integration_bindings', sa.Column('context_source_code', sa.String(length=64), nullable=True))