feat(integration-connector): database 传输类型、两步绑定编排与调用日志捕获查询

- 新增 database 传输:直连 MySQL/Oracle/SQLServer/PostgreSQL 执行绑定 SQL(新增 pymysql/pymssql 驱动依赖)
- 绑定支持 steps_json 多步编排:每步独立传输调用与审计,无 steps 的既有绑定走单步兼容路径
- 客户端实例校验 connector_type ∈ rest/soap/database,database 强制 db_kind 白名单,非 database 置空
- 三个传输层捕获线级事实(最终 SQL/渲染后 XML/原始响应)随调用记录落库,引擎可选透传 business_ref 业务锚点
- 新增调用日志查询 API(列表/详情/同 operation 步骤时间线,仅管理员)与管理端「调用日志」tab:筛选、双栏对照、外部工具复现命令
- 迁移 tt7a/tta9/tt5b:连接器类型枚举、绑定 steps_json、放开 calls 操作唯一约束
- 说明:wire_json 列迁移挂链尾(依赖域表迁移),随后续批次单独落地
This commit is contained in:
hugo committed 2026-09-27 18:05:08 +08:00
1 parent 8a814e7152
commit e750fa8602
47 files changed
+7441 -353

No files matched your search

@@ -0,0 +1,212 @@
/**
* features/admin/modules/integration-connector/IntegrationCallLogsPanel.spec.ts
* 用途:锁定集成调用日志面板行为——挂载即拉列表、筛选带参查询、行点击开抽屉呈现
* wire 关键文本与步骤时间线、复制按钮按连接类型分流(soap=复制 curl,
* database=复制 SQL 绑定内联)、wire_json 为 NULL 的历史行显示「无线级详情」。
* 依赖:vi.mock(./api/integration-connector.api)、@vue/test-utils、i18n。
* 逻辑:mock 列表固定返回 2 行(同 operation_id 两步),详情按用例切换 soap /
* database / 无 wire 三种 wire_json 形态,断言渲染与复制链路。
*/
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import i18n from '@/i18n';
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
import { getIntegrationCall, listIntegrationCalls } from './api/integration-connector.api';
import type {
IntegrationCallDetail,
IntegrationCallLogRow,
} from './types/integration-connector.types';
vi.mock('./api/integration-connector.api', () => ({
listIntegrationCalls: vi.fn(),
getIntegrationCall: vi.fn(),
}));
const mockList = vi.mocked(listIntegrationCalls);
const mockDetail = vi.mocked(getIntegrationCall);
// 列表 2 行:同一次能力调用的 step0(database 成功)+ step1(soap 失败)
const rows: IntegrationCallLogRow[] = [
{
id: 261, created_at: '2026-09-27T00:29:22', capability: 'in_transit_transfer.create_transfer',
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'business_failed',
elapsed_ms: 324, business_ref: 'TGHX1-OR-26092600002', client_code: 'tiptop-ws',
interface_code: 'erp-ws-submit-transfer', connector_type: 'soap', step_index: 1, step_count: 2,
},
{
id: 260, created_at: '2026-09-27T00:29:21', capability: 'in_transit_transfer.create_transfer',
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'success',
elapsed_ms: 2366, business_ref: null, client_code: 'erp-db',
interface_code: 'submit-stage-table', connector_type: 'database', step_index: 0, step_count: 2,
},
];
function makeDetail(call: Partial<IntegrationCallDetail['call']>, wireJson: IntegrationCallDetail['call']['wire_json']): IntegrationCallDetail {
return {
call: {
id: 261, created_at: '2026-09-27T00:29:22', capability: 'in_transit_transfer.create_transfer',
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'business_failed',
elapsed_ms: 324, business_ref: 'TGHX1-OR-26092600002',
binding_snapshot_json: {}, request_summary_json: { doc_no: 'TGHX1-OR-26092600002' },
response_summary_json: { code: 'HTTP_500' }, wire_json: wireJson,
...call,
},
timeline: [
{ id: 260, step_index: 0, step_count: 2, interface_code: 'submit-stage-table', status: 'success', elapsed_ms: 2366 },
{ id: 261, step_index: 1, step_count: 2, interface_code: 'erp-ws-submit-transfer', status: 'business_failed', elapsed_ms: 324 },
],
};
}
const soapDetail = makeDetail({}, {
kind: 'soap', method: 'POST', url: 'http://erp/WS?wsdl', soap_action: '"urn:CreateTransfer"',
request_body: '<soapenv:Envelope><Body>demo</Body></soapenv:Envelope>',
http_status: 500, response_body: '<soapenv:Envelope><Fault/></soapenv:Envelope>',
});
const databaseDetail = makeDetail({ id: 260, status: 'success', elapsed_ms: 2366 }, {
kind: 'database',
statements: [{ phase: 'pre', sql: 'INSERT INTO t (batch) VALUES (:batch)', binds: { batch: 'B1' }, rowcount: 1, row_count: 1 }],
rowcount: 1,
});
const noWireDetail = makeDetail({}, null);
function mountPanel() {
return mount(IntegrationCallLogsPanel, { global: { plugins: [i18n] } });
}
enableAutoUnmount(afterEach);
describe('IntegrationCallLogsPanel', () => {
beforeEach(() => {
vi.clearAllMocks();
mockList.mockResolvedValue({ total: 2, page: 1, page_size: 20, items: rows });
});
it('挂载即拉取列表并渲染 2 行:时间/单号(business_ref 与 operation_id 前 8 位兜底)/步骤', async () => {
// [断言意图] 面板挂载必须自主触发列表查询,不依赖外部触发
const wrapper = mountPanel();
await flushPromises();
expect(mockList).toHaveBeenCalledTimes(1);
expect(wrapper.findAll('[data-testid="call-row"]')).toHaveLength(2);
// 行 261 有 business_ref:单号列显示业务单号
expect(wrapper.text()).toContain('TGHX1-OR-26092600002');
// 行 260 无 business_ref:单号列回退 operation_id 前 8 位
expect(wrapper.text()).toContain('op-cbf5a');
// 步骤列 1-based 展示(step_index 0/1 → 1/2、2/2)、状态徽章含原始状态值、耗时带 ms 后缀
expect(wrapper.text()).toContain('1/2');
expect(wrapper.text()).toContain('2/2');
expect(wrapper.text()).toContain('business_failed');
expect(wrapper.text()).toContain('2366ms');
});
it('填 interface_code 后点查询:带筛选参数且回第一页重新拉取', async () => {
// [断言意图] 筛选值必须原样进入 listIntegrationCalls 入参(querystring 由 api 层拼装)
const wrapper = mountPanel();
await flushPromises();
await wrapper.find('[data-testid="call-filter-interface"]').setValue('erp-ws-submit-transfer');
await wrapper.find('[data-testid="call-filter-query"]').trigger('click');
await flushPromises();
expect(mockList).toHaveBeenCalledTimes(2);
expect(mockList).toHaveBeenLastCalledWith(
expect.objectContaining({ interface_code: 'erp-ws-submit-transfer', page: 1, page_size: 20 }),
);
});
it('点行开详情抽屉:呈现 soap wire 关键文本、两步时间线与复制 operation_id 按钮', async () => {
// [断言意图] 抽屉必须展示线级事实原文(请求 body XML)与同 operation_id 的各步时间线
mockDetail.mockResolvedValue(soapDetail);
const wrapper = mountPanel();
await flushPromises();
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="call-detail-drawer"]').exists()).toBe(true);
expect(wrapper.text()).toContain('<soapenv:Envelope><Body>demo</Body></soapenv:Envelope>');
// 时间线两步均渲染(step1 / step2,1-based 展示),当前步高亮存在
expect(wrapper.text()).toContain('step1');
expect(wrapper.text()).toContain('step2');
expect(wrapper.text()).not.toContain('step0');
expect(wrapper.text()).toContain('submit-stage-table');
expect(wrapper.text()).toContain('erp-ws-submit-transfer');
expect(wrapper.find('[data-testid="call-copy-operation-id"]').exists()).toBe(true);
});
it('soap wire 出现复制 curl,点击后写入的命令含 url 与 SOAPAction', async () => {
// [断言意图] soap 连接类型只提供 curl 复现入口,命令由 buildCurl 生成(可直接粘贴 bash)
const writeText = vi.fn().mockResolvedValue(undefined);
Object.assign(navigator, { clipboard: { writeText } });
mockDetail.mockResolvedValue(soapDetail);
const wrapper = mountPanel();
await flushPromises();
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
await flushPromises();
const curlBtn = wrapper.find('[data-testid="call-copy-curl"]');
expect(curlBtn.exists()).toBe(true);
expect(wrapper.find('[data-testid="call-copy-sql"]').exists()).toBe(false);
await curlBtn.trigger('click');
await flushPromises();
expect(writeText).toHaveBeenCalledTimes(1);
const cmd = String(writeText.mock.calls[0][0]);
expect(cmd).toContain("curl -X POST 'http://erp/WS?wsdl'");
expect(cmd).toContain('SOAPAction');
});
it('database wire 出现复制 SQL(绑定已内联)且不出现复制 curl;写入类带环境警示', async () => {
// [断言意图] database 连接类型只提供 SQL 复现入口,:batch 绑定必须内联为字面量
const writeText = vi.fn().mockResolvedValue(undefined);
Object.assign(navigator, { clipboard: { writeText } });
mockDetail.mockResolvedValue(databaseDetail);
const wrapper = mountPanel();
await flushPromises();
await wrapper.findAll('[data-testid="call-row"]')[1].trigger('click');
await flushPromises();
const sqlBtn = wrapper.find('[data-testid="call-copy-sql"]');
expect(sqlBtn.exists()).toBe(true);
expect(wrapper.find('[data-testid="call-copy-curl"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="call-sql-write-warning"]').exists()).toBe(true);
await sqlBtn.trigger('click');
await flushPromises();
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("INSERT INTO t (batch) VALUES ('B1')"));
});
it('wire_json 为 NULL 的历史行:抽屉显示「无线级详情(历史记录)」且无复制 body/raw 入口', async () => {
// [断言意图] 历史存量不回填,前端必须如实显示无线级详情而非留白或报错
mockDetail.mockResolvedValue(noWireDetail);
const wrapper = mountPanel();
await flushPromises();
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="call-no-wire"]').exists()).toBe(true);
expect(wrapper.text()).toContain('无线级详情(历史记录)');
expect(wrapper.find('[data-testid="call-copy-body"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="call-copy-raw"]').exists()).toBe(false);
});
it('状态下拉与后端 RESULT_STATUSES 七值对齐;duplicate_success 绿 / duplicate_unverified 红', async () => {
// [断言意图] 幂等重放审计行落入 duplicate_* 状态,筛选下拉缺值会导致该类日志无法筛出
mockList.mockResolvedValue({
total: 2, page: 1, page_size: 20,
items: [
{ ...rows[0], id: 270, status: 'duplicate_success', business_ref: null, interface_code: 'if-dup-ok' },
{ ...rows[0], id: 271, status: 'duplicate_unverified', business_ref: null, interface_code: 'if-dup-unverified' },
],
});
const wrapper = mountPanel();
await flushPromises();
const options = wrapper.find('[data-testid="call-filter-status"]').findAll('option')
.map((o) => o.element.value).filter((v) => v !== '');
expect(options).toEqual([
'success', 'duplicate_success', 'duplicate_unverified',
'business_failed', 'technical_failed', 'timeout', 'result_unknown',
]);
// [断言意图] 成功族判定:duplicate_success(幂等重放命中,业务已成功)徽章走绿色成功侧
const dupOkRow = wrapper.findAll('[data-testid="call-row"]')[0];
expect(dupOkRow.text()).toContain('duplicate_success');
expect(dupOkRow.find('span.bg-green-100').exists()).toBe(true);
// [断言意图] duplicate_unverified(回执未核实)保守归非成功态,徽章保持红色 ✗
const dupUnknownRow = wrapper.findAll('[data-testid="call-row"]')[1];
expect(dupUnknownRow.text()).toContain('duplicate_unverified');
expect(dupUnknownRow.find('span.bg-red-100').exists()).toBe(true);
});
});
@@ -23,11 +23,15 @@ const mockState = vi.hoisted(() => {
const bindings = [
{
id: 1, capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
client_instance_code: '1001', interface_definition_code: 'IF-A',
client_instance_code: '1001', interface_definition_code: 'IF-A', steps_json: [],
param_mapping_json: {},
mapping_version: 1, priority: 0, environment: 'prod',
effective_from: null, effective_to: null, status: 'published',
},
];
const interfaces: Array<Record<string, unknown>> = [];
const clients: Array<Record<string, unknown>> = [];
let activeEntity = 'credential';
const credentials = [
{
id: 1, code: 'tiptop-erp', secret_ref: 'db:tiptop-erp', secret_provider: 'db',
@@ -41,14 +45,14 @@ const mockState = vi.hoisted(() => {
},
];
const noop = () => vi.fn();
return { credentials, capabilities, bindings };
return { credentials, capabilities, bindings, interfaces, clients, get activeEntity() { return activeEntity; }, set activeEntity(v: string) { activeEntity = v; } };
});
vi.mock('./composables/useIntegrationConnectorAdmin', () => ({
useIntegrationConnectorAdmin: () => ({
clients: ref([]), interfaces: ref([]), bindings: ref(mockState.bindings),
clients: ref(mockState.clients), interfaces: ref(mockState.interfaces), bindings: ref(mockState.bindings),
credentials: ref(mockState.credentials), capabilities: ref(mockState.capabilities), credentialTypes: ref([]),
isLoading: ref(false), activeEntity: ref('credential'), showFormModal: ref(false), isSaving: ref(false),
isLoading: ref(false), activeEntity: ref(mockState.activeEntity), showFormModal: ref(false), isSaving: ref(false),
clientForm: ref(createEmptyClientInstanceForm()),
interfaceForm: ref(createEmptyInterfaceDefinitionForm()),
bindingForm: ref(createEmptyBindingForm()),
@@ -133,4 +137,47 @@ describe('IntegrationConnectorPage credential list', () => {
expect(text).toContain('在途库存查询');
expect(text).toContain('in_transit_transfer.query_inventory');
});
it('绑定列表按有序步骤渲染接口链与每步客户端;steps_json 为空的存量行走旧列兜底', async () => {
const ifaceRow = (id: number, code: string, name: string, clientCode: string) => ({
id, code, name, client_instance_code: clientCode, connector_type: 'rest', http_method: null,
request_path: null, request_spec_json: {}, input_schema_json: {}, response_mapping_json: {},
output_schema_json: {}, version: 1, status: 'published', enabled: true,
});
const clientRow = (id: number, code: string, name: string) => ({
id, code, name, connector_type: 'rest', environment: 'prod', endpoint: null,
timeout_seconds: null, config_json: {}, credential_ref_code: null, enabled: true,
});
mockState.interfaces = [ifaceRow(1, 'IF-A', '写入中间表', 'CLI-1'), ifaceRow(2, 'IF-B', '回读结果', 'CLI-2')] as never;
mockState.clients = [clientRow(1, 'CLI-1', '生产库'), clientRow(2, 'CLI-2', '生产接口')] as never;
mockState.bindings = [{
id: 9, capability: 'cap.multi', context_selector_json: {},
steps_json: [{ interface_code: 'IF-A', param_mapping_json: {} }, { interface_code: 'IF-B', param_mapping_json: {} }],
param_mapping_json: {}, client_instance_code: 'CLI-1', interface_definition_code: 'IF-A',
mapping_version: 1, priority: 0, environment: 'prod', effective_from: null, effective_to: null, status: 'published',
}] as never;
const wrapper = mountPage();
const bindTab = wrapper.findAll('[role="tab"]').find((b) => b.text() === '绑定')!;
await bindTab.trigger('click');
const text = wrapper.text();
// 两步全部渲染(编号 + 接口名),每步客户端与接口逐步对齐;列头为「接口步骤(有序)」
expect(text).toContain('写入中间表');
expect(text).toContain('回读结果');
expect(text).toContain('生产库');
expect(text).toContain('生产接口');
expect(wrapper.findAll('th').some((th) => th.text().includes('接口步骤'))).toBe(true);
// 存量行兜底:steps_json 为空时由旧单步列合成一步
mockState.bindings = [{
id: 10, capability: 'cap.single', context_selector_json: {}, steps_json: [],
param_mapping_json: {}, client_instance_code: 'CLI-1', interface_definition_code: 'IF-A',
mapping_version: 1, priority: 0, environment: 'prod', effective_from: null, effective_to: null, status: 'draft',
}] as never;
const legacy = mountPage();
const legacyTab = legacy.findAll('[role="tab"]').find((b) => b.text() === '绑定')!;
await legacyTab.trigger('click');
expect(legacy.text()).toContain('写入中间表');
expect(legacy.text()).not.toContain('回读结果');
mockState.bindings = [];
});
});
@@ -1,7 +1,8 @@
<!--
features/admin/modules/integration-connector/IntegrationConnectorPage.vue
用途:集成连接器管理页——四个配置实体(客户端实例/接口定义/绑定/凭据引用)tab 列表 +
能力清单与手动调用测试;创建/编辑抽屉 + 行内连接测试。
能力清单与手动调用测试;创建/编辑抽屉 + 行内连接测试;调用日志 tab
承载筛选/分页列表/详情抽屉(能力无关通用口径)。
依赖:useIntegrationConnectorAdmin、抽屉与调用测试弹窗组件、useI18n。
逻辑:按 tab 展示列表与「新增」;客户端列表展示类型/环境徽章、行内启停开关与
连接测试结果(徽章 + 可展开详情);接口定义与绑定列表均以状态徽章 + 生命周期行内
@@ -19,8 +20,10 @@ import { useI18n } from 'vue-i18n';
import { Plus, Edit, Trash2, Plug, PlayCircle } from 'lucide-vue-next';
import IntegrationConnectorFormDrawer from './components/IntegrationConnectorFormDrawer.vue';
import IntegrationCapabilityCallModal from './components/IntegrationCapabilityCallModal.vue';
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
import { CONNECTOR_TYPE_OPTIONS, ENVIRONMENT_OPTIONS } from './types/integration-connector.types';
import { useIntegrationConnectorAdmin } from './composables/useIntegrationConnectorAdmin';
import type { IntegrationBindingRow } from './types/integration-connector.types';
const { t } = useI18n();
@@ -38,16 +41,17 @@ const {
onMounted(() => { void loadAll(); });
type TabKey = 'client' | 'interface' | 'binding' | 'credential' | 'capability';
type TabKey = 'client' | 'interface' | 'binding' | 'credential' | 'capability' | 'calls';
const tabs: Array<{ key: TabKey; labelKey: string }> = [
{ key: 'client', labelKey: 'admin.integrationConnector.tabs.client' },
{ key: 'interface', labelKey: 'admin.integrationConnector.tabs.interface' },
{ key: 'binding', labelKey: 'admin.integrationConnector.tabs.binding' },
{ key: 'credential', labelKey: 'admin.integrationConnector.tabs.credential' },
{ key: 'capability', labelKey: 'admin.integrationConnector.tabs.capability' },
{ key: 'calls', labelKey: 'admin.integrationConnector.tabs.calls' },
];
// 当前激活 tab:页面本地状态(capability 为只读注册表 tab,不属于可编辑实体);
// 初始取 activeEntity,保证携带实体态进入页面时列表与 tab 一致。
// 当前激活 tab:页面本地状态(capability 为只读注册表 tab,calls 为只读调用日志 tab,
// 均不属于可编辑实体);初始取 activeEntity,保证携带实体态进入页面时列表与 tab 一致。
const activeTab = ref<TabKey>(activeEntity.value);
/** 客户端选项带 connector_type:接口表单联动展示连接器类型用。 */
@@ -64,6 +68,18 @@ function clientNameOf(code: string) {
function interfaceNameOf(code: string) {
return interfaces.value.find((i) => i.code === code)?.name ?? '';
}
/** 绑定有序步骤视图:优先 steps_json;存量旧列行(P2 前镜像)兜底合成一步。
* 每步客户端由接口归属自带,供客户端列按步骤对齐展示。
*/
function bindingStepsOf(row: IntegrationBindingRow): Array<{ interface_code: string; client_code: string }> {
const steps = row.steps_json?.length
? row.steps_json
: [{ interface_code: row.interface_definition_code, param_mapping_json: row.param_mapping_json ?? {} }];
return steps.map((step) => ({
interface_code: step.interface_code,
client_code: interfaces.value.find((iface) => iface.code === step.interface_code)?.client_instance_code ?? row.client_instance_code,
}));
}
/** 行内展开测试详情的客户端编码(同一时刻至多展开一行)。 */
const expandedTestCode = ref('');
@@ -148,8 +164,8 @@ function testDetailText(code: string) {
function selectTab(key: TabKey) {
activeTab.value = key;
// capability tab 只读展示注册表(无新增/表单入口),activeEntity 保持最后一个可编辑实体供抽屉复用。
if (key !== 'capability') activeEntity.value = key;
// capability/calls tab 只读展示(无新增/表单入口),activeEntity 保持最后一个可编辑实体供抽屉复用。
if (key !== 'capability' && key !== 'calls') activeEntity.value = key;
}
</script>
@@ -161,7 +177,7 @@ function selectTab(key: TabKey) {
<p class="section-desc mt-1">{{ t('admin.integrationConnector.subtitle') }}</p>
</div>
<button
v-if="activeTab !== 'capability'"
v-if="activeTab !== 'capability' && activeTab !== 'calls'"
type="button"
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
@click="openCreateModal(activeEntity)"
@@ -371,12 +387,16 @@ function selectTab(key: TabKey) {
<p v-if="capabilityLabelOf(row.capability) !== row.capability" class="text-xs text-muted mono mt-0.5">{{ row.capability }}</p>
</td>
<td class="px-6 py-4">
<p class="text-sm text-primary">{{ clientNameOf(row.client_instance_code) || row.client_instance_code }}</p>
<p class="text-xs text-muted mono mt-0.5">{{ row.client_instance_code }}</p>
<!-- 有序步骤:逐步渲染客户端(与接口步骤列对齐) -->
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`c-${step.interface_code}-${idx}`" class="text-sm text-primary">
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span>{{ clientNameOf(step.client_code) || step.client_code }}
</p>
</td>
<td class="px-6 py-4">
<p class="text-sm text-primary">{{ interfaceNameOf(row.interface_definition_code) || row.interface_definition_code }}</p>
<p class="text-xs text-muted mono mt-0.5">{{ row.interface_definition_code }}</p>
<!-- 有序步骤编排:编号 + 接口名,悬停显示接口编码;旧单步行兜底为一步 -->
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`i-${step.interface_code}-${idx}`" class="text-sm text-primary">
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span><span :title="step.interface_code">{{ interfaceNameOf(step.interface_code) || step.interface_code }}</span>
</p>
</td>
<td class="px-6 py-4">
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium" :class="statusBadgeClass(row.status)" data-testid="binding-status">{{ statusLabel(row.status) }}</span>
@@ -478,6 +498,9 @@ function selectTab(key: TabKey) {
</table>
</div>
<!-- 调用日志:筛选 + 分页列表 + 详情抽屉(能力无关通用口径;只读 tab,无新增入口) -->
<IntegrationCallLogsPanel v-else-if="activeTab === 'calls'" />
<!-- 能力清单 -->
<div v-else class="admin-table-wrap">
<table class="admin-table">
@@ -1,6 +1,6 @@
/**
* features/admin/modules/integration-connector/api/integration-connector.api.ts
* 集成连接器管理 API 客户端:客户端实例/接口定义/绑定/凭据引用 CRUD + 能力清单 + 连接测试。
* 集成连接器管理 API 客户端:客户端实例/接口定义/绑定/凭据引用 CRUD + 能力清单 + 连接测试 + 调用日志查询。
* 依赖:@/shared/api/client(requestJson / BusinessError)、@/shared/utils/auth。
* 逻辑:薄封装后端 /api/integration-connector/* 全部端点;JSON 写请求带 Content-Type。
* 错误码(INTEGRATION.*)由 requestJson 解析到四语言文案。
@@ -9,6 +9,9 @@ import { requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
import type {
IntegrationBindingRow,
IntegrationCallDetail,
IntegrationCallFilters,
IntegrationCallLogRow,
IntegrationCallResultRow,
IntegrationCapabilityRow,
IntegrationClientInstanceRow,
@@ -121,3 +124,31 @@ export const updateIntegrationCredentialReference = (code: string, payload: Reco
requestJson<IntegrationCredentialReferenceRow>(`${BASE}/credential-references/${encodeURIComponent(code)}`, {
method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload),
});
// ---- 调用日志 ----
/**
* 把调用日志筛选对象序列化为 querystring。
* 约束:过滤 undefined / null / 空串(空筛选拼出无参 URL);数字(page/page_size)转字符串。
* 返回值:形如 `?a=1&b=2`(无有效参数时为空串),直接拼接在端点路径后。
*/
function buildCallLogQuery(filters: IntegrationCallFilters): string {
const search = new URLSearchParams();
Object.entries(filters).forEach(([key, value]) => {
if (value === undefined || value === null || String(value).trim() === '') return;
search.set(key, String(value));
});
const qs = search.toString();
return qs ? `?${qs}` : '';
}
/** 集成调用日志分页查询(能力无关;keyword 对请求摘要 JSON 模糊)。 */
export const listIntegrationCalls = (filters: IntegrationCallFilters = {}) =>
requestJson<{ total: number; page: number; page_size: number; items: IntegrationCallLogRow[] }>(
`${BASE}/calls${buildCallLogQuery(filters)}`,
auth(),
);
/** 调用全量详情(含 wire_json 与同 operation_id 步骤时间线)。 */
export const getIntegrationCall = (id: number) =>
requestJson<IntegrationCallDetail>(`${BASE}/calls/${id}`, auth());
@@ -0,0 +1,493 @@
<!--
features/admin/modules/integration-connector/components/IntegrationCallLogsPanel.vue
用途:集成调用日志面板——筛选条 + 分页列表 + 行点击详情抽屉(能力无关通用口径)。
依赖:../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
../utils/integration-call-replay(buildCurl / buildSqlReplay)、
useMessage、copyTextToClipboard、formatLocalDateTime、useI18n。
逻辑:筛选(接口编码/客户端编码/连接类型/状态/operation_id/trace_id/业务单号/
参数关键字/执行时间起止)回车或点「查询」生效(查询回第一页),「重置」清空;
列表按 id 倒序分页,行点击拉取全量详情开右侧抽屉;抽屉含步骤时间线
(同 operation_id 各步、当前步高亮)、线级请求与业务参数双栏、原始报文与
归一化 JSON 双栏;复制按钮组按连接类型分流:soap/rest=复制 body / 复制 curl,
database=复制 SQL(绑定已内联、写入类自动包事务并红字警示),
另有复制原始报文 / 复制 JSON / 复制 operation_id / 复制 trace_id;
wire_json 为 NULL(历史存量行)时如实显示「无线级详情(历史记录)」,不回填。
-->
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { ChevronLeft, ChevronRight, X } from 'lucide-vue-next';
import { useMessage } from '@/shared/composables/useMessage';
import { copyTextToClipboard } from '@/shared/utils/clipboard';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import { getIntegrationCall, listIntegrationCalls } from '../api/integration-connector.api';
import {
CONNECTOR_TYPE_OPTIONS,
type IntegrationCallDetail,
type IntegrationCallFilters,
type IntegrationCallLogRow,
type IntegrationCallWire,
} from '../types/integration-connector.types';
import { buildCurl, buildSqlReplay } from '../utils/integration-call-replay';
/**
* 调用状态固定枚举(与后端 RESULT_STATUSES 七值对齐,含幂等重放的
* duplicate_success / duplicate_unverified 审计行;下拉直接用原始值,未注册翻译兜底)。
*/
const CALL_STATUS_OPTIONS = [
'success', 'duplicate_success', 'duplicate_unverified', 'business_failed',
'technical_failed', 'timeout', 'result_unknown',
] as const;
const { t } = useI18n();
const { error: notifyError, success: notifySuccess } = useMessage();
const filters = ref<IntegrationCallFilters>({});
const items = ref<IntegrationCallLogRow[]>([]);
const total = ref(0);
const page = ref(1);
const pageSize = 20;
const loading = ref(false);
const detail = ref<IntegrationCallDetail | null>(null);
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)));
/** 当前详情的线级事实(null = 历史存量行或未捕获场景,抽屉如实显示「无线级详情」)。 */
const wire = computed<IntegrationCallWire | null>(() => detail.value?.call.wire_json ?? null);
/** soap/rest 的 wire 头部元信息(method/url/SOAPAction/headers)拼接为多行文本。 */
const wireMetaText = computed(() => {
const w = wire.value;
if (!w || w.kind === 'database') return '';
const lines = [`method: ${w.method ?? '-'}`, `url: ${w.url ?? '-'}`];
if (w.soap_action !== undefined) lines.push(`SOAPAction: ${w.soap_action}`);
if (w.headers) lines.push(`headers: ${w.headers}`);
return lines.join('\n');
});
/** database 的 SQL 复现文本(绑定已内联;写入类自动包 BEGIN…ROLLBACK 事务)。 */
const sqlReplayText = computed(() =>
wire.value && wire.value.kind === 'database' ? buildSqlReplay(wire.value) : '',
);
/** database 写入类语句红字警示显隐(防复现时误写目标库)。 */
const hasWriteStatement = computed(() =>
(wire.value?.statements ?? []).some((s) => /^\s*(INSERT|UPDATE|DELETE|MERGE)/im.test(s.sql)),
);
/** soap/rest 的 curl 复现命令(凭据位 ***REDACTED***,需手工替换)。 */
const curlCommand = computed(() =>
wire.value && wire.value.kind !== 'database' ? buildCurl(wire.value) : '',
);
/** 响应区原始报文文本:soap/rest=HTTP 状态行 + 响应报文;database=查询行集(无线级时兜底行数)。 */
const rawResponseText = computed(() => {
const w = wire.value;
if (!w) return '';
if (w.kind === 'database') {
return w.rows ? prettyJson(w.rows) : `rowcount: ${w.rowcount ?? '-'}`;
}
return `HTTP ${w.http_status ?? '-'}\n${w.response_body ?? ''}`;
});
/** 拉取列表(当前筛选 + 当前页);失败经全局错误弹窗提示。 */
async function load() {
loading.value = true;
try {
const data = await listIntegrationCalls({ ...filters.value, page: page.value, page_size: pageSize });
items.value = data.items;
total.value = data.total;
} catch (e) {
notifyError(e instanceof Error ? e.message : String(e));
} finally {
loading.value = false;
}
}
/** 应用筛选并回第一页(回车或「查询」按钮触发)。 */
function query() {
page.value = 1;
void load();
}
/** 清空全部筛选项并回第一页重新拉取。 */
function resetFilters() {
filters.value = {};
query();
}
function goPrev() {
if (page.value > 1) {
page.value -= 1;
void load();
}
}
function goNext() {
if (page.value < totalPages.value) {
page.value += 1;
void load();
}
}
/** 点列表行拉全量详情(含 wire_json 与同 operation_id 时间线)并开抽屉。 */
async function openDetail(row: IntegrationCallLogRow) {
try {
detail.value = await getIntegrationCall(row.id);
} catch (e) {
notifyError(e instanceof Error ? e.message : String(e));
}
}
function closeDetail() {
detail.value = null;
}
/** 抽屉打开时 Esc 关闭(与表单抽屉行为一致)。 */
function onEscKey(e: KeyboardEvent) {
if (e.key === 'Escape' && detail.value) closeDetail();
}
/** 复制文本到剪贴板(带降级方案),成功后弹「已复制」提示。 */
async function copy(text: string) {
const ok = await copyTextToClipboard(text);
if (ok) notifySuccess(t('admin.integrationConnector.callLogs.copied'));
}
/**
* 调用成功族判定:success 与 duplicate_success(幂等重放命中,业务已成功)同属成功侧;
* duplicate_unverified(重放命中但回执未核实)保守归非成功态展示。
*/
function isSuccess(status: string): boolean {
return status === 'success' || status === 'duplicate_success';
}
/** 状态徽标配色:成功绿 / 其余红。 */
function statusBadgeClass(status: string): string {
return isSuccess(status) ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700';
}
/** 状态图标:✓ 成功 / ✗ 失败。 */
function statusIcon(status: string): string {
return isSuccess(status) ? '✓' : '✗';
}
/** 单号列文本:优先业务单号 business_ref,未透传时回退 operation_id 前 8 位。 */
function refTextOf(row: IntegrationCallLogRow): string {
return row.business_ref || row.operation_id.slice(0, 8);
}
/** 步骤列文本:1-based 序号/总步数(对用户展示从 1 计;存储的 step_index 为 0-based 引擎下标;缺值显示 -)。 */
function stepText(row: IntegrationCallLogRow): string {
if (row.step_index === null || row.step_index === undefined) return '-/-';
return `${row.step_index + 1}/${row.step_count ?? '?'}`;
}
/** 时间线步骤标签:1-based 序号(与列表口径一致)。 */
function stepLabel(entry: { step_index: number | null; step_count: number | null }, idx: number): string {
const base = entry.step_index ?? idx;
return `step${base + 1}`;
}
/** 语句行数:rowcount / row_count 双字段名并存(实现版本差异),两者都读。 */
function statementRowCount(s: { rowcount?: number; row_count?: number }): string {
const n = s.rowcount ?? s.row_count;
return n === undefined ? '' : String(n);
}
/** 时间线条目是否为当前查看的调用(抽屉时间线高亮当前步)。 */
function isCurrentStep(entry: IntegrationCallDetail['timeline'][number]): boolean {
return detail.value != null && entry.id === detail.value.call.id;
}
function prettyJson(value: unknown): string {
return JSON.stringify(value, null, 2);
}
onMounted(() => {
window.addEventListener('keydown', onEscKey);
void load();
});
onBeforeUnmount(() => {
window.removeEventListener('keydown', onEscKey);
});
</script>
<template>
<div class="space-y-4">
<!-- 筛选条:全部可选,回车 / 点查询生效 -->
<div class="rounded-xl border border-default bg-surface p-4 space-y-3">
<div class="grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5" @keyup.enter="query">
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterInterface') }}</label>
<input v-model="filters.interface_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-interface" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterClient') }}</label>
<input v-model="filters.client_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-client" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterConnector') }}</label>
<select v-model="filters.connector_type" class="input-field text-sm" data-testid="call-filter-connector">
<option value="">—</option>
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterStatus') }}</label>
<select v-model="filters.status" class="input-field text-sm font-mono" data-testid="call-filter-status">
<option value="">—</option>
<option v-for="s in CALL_STATUS_OPTIONS" :key="s" :value="s">{{ s }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterOperationId') }}</label>
<input v-model="filters.operation_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-operation-id" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterTraceId') }}</label>
<input v-model="filters.trace_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-trace-id" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}</label>
<input v-model="filters.business_ref" type="text" class="input-field text-sm font-mono" data-testid="call-filter-business-ref" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterKeyword') }}</label>
<input v-model="filters.keyword" type="text" class="input-field text-sm" data-testid="call-filter-keyword" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateFrom') }}</label>
<input v-model="filters.date_from" type="date" class="input-field text-sm" data-testid="call-filter-date-from" />
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateTo') }}</label>
<input v-model="filters.date_to" type="date" class="input-field text-sm" data-testid="call-filter-date-to" />
</div>
</div>
<div class="flex gap-2">
<button type="button" class="btn-primary" data-testid="call-filter-query" @click="query">
{{ t('admin.integrationConnector.callLogs.query') }}
</button>
<button type="button" class="btn-ghost" data-testid="call-filter-reset" @click="resetFilters">
{{ t('admin.integrationConnector.callLogs.reset') }}
</button>
</div>
</div>
<!-- 调用记录列表(id 倒序;行点击开详情抽屉) -->
<div class="admin-table-wrap" :class="loading ? 'opacity-60 pointer-events-none' : ''">
<div class="px-4 py-3 flex items-center justify-between">
<h4 class="text-sm font-bold text-primary">{{ t('admin.integrationConnector.callLogs.title') }}</h4>
<span class="text-xs text-muted font-mono">({{ total }})</span>
</div>
<table class="admin-table">
<thead>
<tr>
<th class="px-4 py-3 text-left text-xs w-16">#</th>
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colTime') }}</th>
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colCapability') }}</th>
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colInterface') }}</th>
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colRef') }}</th>
<th class="px-4 py-3 text-left text-xs w-20">{{ t('admin.integrationConnector.callLogs.colStep') }}</th>
<th class="px-4 py-3 text-left text-xs w-44">{{ t('admin.integrationConnector.callLogs.colStatus') }}</th>
<th class="px-4 py-3 text-right text-xs w-24">{{ t('admin.integrationConnector.callLogs.colElapsed') }}</th>
</tr>
</thead>
<tbody>
<tr v-if="items.length === 0">
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td>
</tr>
<tr
v-for="row in items"
:key="row.id"
data-testid="call-row"
class="cursor-pointer hover:bg-surface-soft transition-colors"
@click="openDetail(row)"
>
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.id }}</td>
<td class="px-4 py-3 text-xs text-secondary font-mono whitespace-nowrap">{{ formatLocalDateTime(row.created_at) }}</td>
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[220px]"><span class="block truncate" :title="row.capability">{{ row.capability }}</span></td>
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[200px]"><span class="block truncate" :title="row.interface_code || ''">{{ row.interface_code || '—' }}</span></td>
<td class="px-4 py-3 text-xs font-mono text-secondary" :title="row.business_ref || row.operation_id">{{ refTextOf(row) }}</td>
<td class="px-4 py-3 text-xs text-secondary font-mono">{{ stepText(row) }}</td>
<td class="px-4 py-3">
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(row.status)">
{{ statusIcon(row.status) }} {{ row.status }}
</span>
</td>
<td class="px-4 py-3 text-xs text-secondary font-mono text-right whitespace-nowrap">{{ row.elapsed_ms }}ms</td>
</tr>
</tbody>
</table>
<div class="flex items-center justify-end gap-3 px-4 py-3 text-xs text-secondary">
<button
type="button"
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
:title="t('admin.integrationConnector.callLogs.prevPage')"
data-testid="call-prev-page"
:disabled="page <= 1 || loading"
@click="goPrev"
>
<ChevronLeft class="w-4 h-4" />
</button>
<span class="font-mono">{{ page }} / {{ totalPages }}</span>
<button
type="button"
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
:title="t('admin.integrationConnector.callLogs.nextPage')"
data-testid="call-next-page"
:disabled="page >= totalPages || loading"
@click="goNext"
>
<ChevronRight class="w-4 h-4" />
</button>
</div>
</div>
<!-- 详情抽屉:右侧滑出(步骤时间线 + 线级/归一化双栏 + 复现命令复制) -->
<div
v-if="detail"
class="fixed inset-0 z-50 flex justify-end bg-overlay animate-fade-in"
data-testid="call-detail-drawer"
@click.self="closeDetail"
>
<aside role="dialog" aria-modal="true" :aria-label="t('admin.integrationConnector.callLogs.detailTitle')" class="h-full w-full max-w-4xl flex flex-col bg-surface shadow-2xl outline-none">
<div class="px-5 sm:px-8 pt-5 sm:pt-6 pb-4 border-b border-default shrink-0 space-y-2">
<div class="flex items-start justify-between gap-3">
<h3 class="section-title">{{ t('admin.integrationConnector.callLogs.detailTitle') }} #{{ detail.call.id }}</h3>
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :aria-label="t('admin.cancel')" data-testid="call-detail-close" @click="closeDetail">
<X class="w-4 h-4" />
</button>
</div>
<div class="flex flex-wrap gap-x-6 gap-y-1 text-xs text-secondary">
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colCapability') }}: </span><span class="font-mono">{{ detail.call.capability }}</span></span>
<span>
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.colStatus') }}: </span>
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(detail.call.status)">
{{ statusIcon(detail.call.status) }} {{ detail.call.status }}
</span>
</span>
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colElapsed') }}: </span><span class="font-mono">{{ detail.call.elapsed_ms }}ms</span></span>
<span v-if="detail.call.business_ref">
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}: </span><span class="font-mono">{{ detail.call.business_ref }}</span>
</span>
</div>
<div class="flex flex-wrap items-center gap-x-6 gap-y-1 text-xs">
<span class="flex items-center gap-1.5 min-w-0">
<span class="text-muted font-mono shrink-0">operation:</span>
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.operation_id">{{ detail.call.operation_id }}</span>
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-operation-id" @click="copy(detail.call.operation_id)">
{{ t('admin.integrationConnector.callLogs.copyOperationId') }}
</button>
</span>
<span class="flex items-center gap-1.5 min-w-0">
<span class="text-muted font-mono shrink-0">trace:</span>
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.trace_id">{{ detail.call.trace_id }}</span>
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-trace-id" @click="copy(detail.call.trace_id)">
{{ t('admin.integrationConnector.callLogs.copyTraceId') }}
</button>
</span>
</div>
</div>
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto flex-1">
<!-- 步骤时间线:同一次能力调用的 N 步(当前步高亮) -->
<section class="space-y-2">
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.timeline') }}</h4>
<div class="flex flex-wrap items-center gap-2">
<template v-for="(entry, idx) in detail.timeline" :key="entry.id">
<div class="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs" :class="isCurrentStep(entry) ? 'bg-brand-50 ring-1 ring-brand-300' : 'bg-surface-soft'">
<span class="inline-block w-2 h-2 rounded-full shrink-0" :class="isSuccess(entry.status) ? 'bg-green-500' : 'bg-red-500'" />
<span class="font-mono text-muted">{{ stepLabel(entry, idx) }}</span>
<span class="text-secondary font-medium font-mono">{{ entry.interface_code || '—' }}</span>
<span class="font-mono" :class="isSuccess(entry.status) ? 'text-green-600' : 'text-red-600'">{{ statusIcon(entry.status) }} {{ entry.status }}</span>
<span class="text-muted font-mono">{{ entry.elapsed_ms }}ms</span>
</div>
<span v-if="idx < detail.timeline.length - 1" class="text-muted" aria-hidden="true">──</span>
</template>
</div>
</section>
<!-- 请求:线级请求(wire)+ 业务参数(归一化)双栏 -->
<section class="space-y-2">
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.request') }}</h4>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.wire') }}</h5>
<template v-if="wire">
<!-- soap/rest:method/url/SOAPAction/headers + 完整请求 body XML -->
<template v-if="wire.kind !== 'database'">
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ wireMetaText }}</pre>
<div class="text-xs text-muted font-mono">── request_body ──</div>
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ wire.request_body }}</pre>
<div class="flex flex-wrap gap-2">
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-body" @click="copy(wire.request_body || '')">
{{ t('admin.integrationConnector.callLogs.copyBody') }}
</button>
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-curl" @click="copy(curlCommand)">
{{ t('admin.integrationConnector.callLogs.copyCurl') }}
</button>
</div>
</template>
<!-- database:pre/bulk/post 三段最终 SQL + 绑定首行 + 行数;写入类红字警示 -->
<template v-else>
<div v-for="(s, idx) in wire.statements || []" :key="idx" class="space-y-1">
<div class="flex items-center gap-2">
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-surface-soft text-secondary font-mono">{{ s.phase }}</span>
<span v-if="statementRowCount(s)" class="text-xs text-muted font-mono">rows: {{ statementRowCount(s) }}</span>
</div>
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ s.sql }}</pre>
<pre v-if="s.binds && Object.keys(s.binds).length > 0" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-muted whitespace-pre-wrap break-all">{{ prettyJson(s.binds) }}</pre>
</div>
<div v-if="wire.rowcount !== undefined" class="text-xs text-muted font-mono">rowcount: {{ wire.rowcount }}</div>
<p v-if="hasWriteStatement" class="text-xs font-medium text-red-600" data-testid="call-sql-write-warning">
{{ t('admin.integrationConnector.callLogs.sqlWriteWarning') }}
</p>
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-sql" @click="copy(sqlReplayText)">
{{ t('admin.integrationConnector.callLogs.copySql') }}
</button>
</template>
</template>
<!-- 历史存量行 / 未捕获场景:wire_json 为 NULL,如实展示不回填 -->
<p v-else class="text-xs text-muted" data-testid="call-no-wire">
{{ t('admin.integrationConnector.callLogs.noWire') }}
</p>
</div>
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalized') }}</h5>
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.request_summary_json) }}</pre>
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-request-json" @click="copy(prettyJson(detail.call.request_summary_json))">
{{ t('admin.integrationConnector.callLogs.copyJson') }}
</button>
</div>
</div>
</section>
<!-- 响应:原始报文 + 归一化 JSON 双栏 -->
<section class="space-y-2">
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.response') }}</h4>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.rawPayload') }}</h5>
<pre v-if="wire" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ rawResponseText }}</pre>
<p v-else class="text-xs text-muted" data-testid="call-no-wire-response">{{ t('admin.integrationConnector.callLogs.noWire') }}</p>
<button v-if="wire" type="button" class="btn-ghost text-xs" data-testid="call-copy-raw" @click="copy(rawResponseText)">
{{ t('admin.integrationConnector.callLogs.copyRaw') }}
</button>
</div>
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalizedJson') }}</h5>
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.response_summary_json) }}</pre>
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-response-json" @click="copy(prettyJson(detail.call.response_summary_json))">
{{ t('admin.integrationConnector.callLogs.copyJson') }}
</button>
</div>
</div>
</section>
</div>
</aside>
</div>
</div>
</template>
@@ -1,8 +1,9 @@
/**
* features/admin/modules/integration-connector/components/IntegrationConnectorFormDrawer.spec.ts
* 用途:锁定表单按连接器类型动态显示字段——REST 显示超时/HTTP方法/请求路径,
* SOAP 显示 WSDL;以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、
* 脏检查关闭确认与 Esc 关闭行为。
* SOAP 显示 WSDL,database 显示 db_kind 专属下拉与数据库连接串 label;
* 绑定表单的有序步骤编辑器(添加/删除/上移下移/每步独立参数映射);
* 以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、脏检查关闭确认与 Esc 关闭行为。
* 依赖:@vue/test-utils、vitest、i18n。
* 逻辑:切换 connector_type 断言字段可见性;对 JsonTextareaField 断言格式化改写
* 与非法 JSON 提示;mock window.confirm 断言脏表单关闭拦截与放行。
@@ -13,11 +14,13 @@ import i18n from '@/i18n';
import IntegrationConnectorFormDrawer from './IntegrationConnectorFormDrawer.vue';
import JsonTextareaField from './JsonTextareaField.vue';
import {
bindingRowToForm,
createEmptyClientInstanceForm,
createEmptyInterfaceDefinitionForm,
createEmptyBindingForm,
createEmptyCredentialReferenceForm,
type InterfaceDefinitionFormState,
type IntegrationBindingRow,
} from '../types/integration-connector.types';
enableAutoUnmount(afterEach);
@@ -117,7 +120,7 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
expect(chip.attributes('title')).toContain('发布');
});
it('绑定:选定接口定义后客户端实例自动带出并锁定', async () => {
it('绑定:添加步骤并选接口后,只读提示该步接口归属的客户端实例', async () => {
const bindingForm = createEmptyBindingForm();
const wrapper = mountDrawer({
activeEntity: 'binding',
@@ -128,12 +131,12 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
],
interfaceOptions: [{ code: '1001-iface', name: '接口A', client_instance_code: '1001' }],
});
// 未选接口定义前客户端实例可维护
expect(wrapper.find('[data-testid="binding-client"]').attributes('disabled')).toBeUndefined();
await wrapper.find('[data-testid="binding-interface"]').setValue('1001-iface');
// 选定接口定义后:客户端实例按接口归属联动带出且锁定
expect(bindingForm.client_instance_code).toBe('1001');
expect(wrapper.find('[data-testid="binding-client"]').attributes('disabled')).toBeDefined();
// 绑定表单不再单独维护客户端实例下拉(client 由各步接口归属自带)
expect(wrapper.find('[data-testid="binding-client"]').exists()).toBe(false);
// 添加一步并选择接口定义 → 只读提示其归属客户端实例
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('1001-iface');
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('1001');
});
it('绑定能力下拉选项本地化:有翻译显示「中文名(注册名)」,无翻译兜底注册名', () => {
@@ -153,6 +156,143 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
});
});
describe('IntegrationConnectorFormDrawer database connector type', () => {
it('类型下拉含「数据库直连」;选中后显示 db_kind 四选一下拉、数据库连接串 label,超时照显', async () => {
const wrapper = mountDrawer();
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
// 非 database 类型不渲染 db_kind 下拉
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
const dbKind = wrapper.find('[data-testid="client-db-kind"]');
expect(dbKind.exists()).toBe(true);
// db_kind 专属下拉四选一(含未选占位项),label 即库名
expect(dbKind.findAll('option').map((o) => o.text())).toEqual(['—', 'MySQL', 'Oracle', 'SQL Server', 'PostgreSQL']);
// endpoint label 切换为数据库连接串语义;超时字段照常显示
const labels = wrapper.findAll('label').map((l) => l.text());
expect(labels.some((t) => t.includes('数据库连接串'))).toBe(true);
expect(wrapper.find('[data-testid="client-timeout"]').exists()).toBe(true);
});
it('database 类型不显示 HTTP 方法/请求路径(接口表单随客户端联动 database 类型)', async () => {
const interfaceForm = createEmptyInterfaceDefinitionForm();
const wrapper = mountDrawer({
activeEntity: 'interface',
interfaceForm,
clientOptions: [{ code: 'erp-db', name: 'ERP Oracle', connector_type: 'database' }],
});
await wrapper.find('[data-testid="interface-client"]').setValue('erp-db');
// 接口类型随客户端联动为 database
expect(interfaceForm.connector_type).toBe('database');
const labels = wrapper.findAll('label').map((l) => l.text());
expect(labels.some((t) => t.includes('HTTP 方法'))).toBe(false);
expect(labels.some((t) => t.includes('请求路径'))).toBe(false);
// 类型只读下拉显示本地化 database 文案
expect(wrapper.find('[data-testid="interface-connector-type"]').text()).toContain('数据库直连');
});
it('切回非 database 类型后 db_kind 下拉隐藏且残留值清空', async () => {
const clientForm = createEmptyClientInstanceForm();
const wrapper = mountDrawer({ clientForm });
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
await wrapper.find('[data-testid="client-db-kind"]').setValue('oracle');
expect(clientForm.db_kind).toBe('oracle');
await wrapper.find('[data-testid="client-connector-type"]').setValue('rest');
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
expect(clientForm.db_kind).toBe('');
});
it('database 类型高级配置提示列出生效键 oracle_lib_dir', async () => {
const wrapper = mountDrawer();
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
expect(wrapper.text()).toContain('"oracle_lib_dir"');
});
});
describe('IntegrationConnectorFormDrawer binding steps editor', () => {
function mountBinding(overrides: Partial<Record<string, unknown>> = {}) {
return mountDrawer({
activeEntity: 'binding',
clientOptions: [
{ code: 'erp-db', name: 'ERP Oracle', connector_type: 'database' },
{ code: 'tiptop-ws', name: '鼎捷WS', connector_type: 'soap' },
],
interfaceOptions: [
{ code: 'IF-STAGE', name: '写中间表', client_instance_code: 'erp-db' },
{ code: 'IF-SUBMIT', name: '触发WS', client_instance_code: 'tiptop-ws' },
],
...overrides,
});
}
it('接口从单选改为有序多选:添加两步,每步独立接口下拉与归属客户端只读提示', async () => {
const bindingForm = createEmptyBindingForm();
const wrapper = mountBinding({ bindingForm });
// 空态无步骤行
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(0);
// 添加两步
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
expect(bindingForm.steps).toHaveLength(2);
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
// 每步显示归属客户端只读提示(跨客户端步骤:database + soap)
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
expect(wrapper.find('[data-testid="binding-step-client-1"]').text()).toContain('tiptop-ws');
});
it('上移/下移重排步骤顺序;首步无上移、末步无下移(禁用)', async () => {
const bindingForm = createEmptyBindingForm();
const wrapper = mountBinding({ bindingForm });
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
expect(wrapper.find('[data-testid="binding-step-up-0"]').attributes('disabled')).toBeDefined();
expect(wrapper.find('[data-testid="binding-step-down-1"]').attributes('disabled')).toBeDefined();
// 下移首步 → 顺序翻转
await wrapper.find('[data-testid="binding-step-down-0"]').trigger('click');
expect(bindingForm.steps[0].interface_code).toBe('IF-SUBMIT');
expect(bindingForm.steps[1].interface_code).toBe('IF-STAGE');
// 再上移还原
await wrapper.find('[data-testid="binding-step-up-1"]').trigger('click');
expect(bindingForm.steps[0].interface_code).toBe('IF-STAGE');
expect(bindingForm.steps[1].interface_code).toBe('IF-SUBMIT');
});
it('删除步骤移除对应行;每步参数映射独立编辑写回对应步骤', async () => {
const bindingForm = createEmptyBindingForm();
const wrapper = mountBinding({ bindingForm });
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
// 每步独立的 param_mapping JSON 编辑(沿用 JsonTextareaField 交互)
const stepRows = wrapper.findAll('[data-testid="binding-step-row"]');
await stepRows[0].findComponent(JsonTextareaField).find('[data-testid="json-textarea"]')
.setValue('{"erp_org":{"expr":"external_org"}}');
expect(bindingForm.steps[0].param_mapping_json).toBe('{"erp_org":{"expr":"external_org"}}');
expect(bindingForm.steps[1].param_mapping_json).toBe('');
// 删除首步 → 只剩原第二步
await wrapper.find('[data-testid="binding-step-remove-0"]').trigger('click');
expect(bindingForm.steps).toHaveLength(1);
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
});
it('既有单接口绑定编辑回归:steps_json 单步行回显为一步且接口预选', () => {
const bindingForm = bindingRowToForm({
id: 5, capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
steps_json: [{ interface_code: 'IF-STAGE', param_mapping_json: { erp_org: { expr: 'external_org' } } }],
param_mapping_json: { erp_org: { expr: 'external_org' } },
client_instance_code: 'erp-db', interface_definition_code: 'IF-STAGE',
mapping_version: 1, priority: 0, environment: 'prod',
effective_from: null, effective_to: null, status: 'draft',
} as IntegrationBindingRow);
const wrapper = mountBinding({ bindingForm });
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
expect((wrapper.find('[data-testid="binding-step-interface-0"]').element as HTMLSelectElement).value).toBe('IF-STAGE');
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
});
});
describe('IntegrationConnectorFormDrawer JSON fields', () => {
function findJsonField(wrapper: ReturnType<typeof mountDrawer>, labelPart: string) {
const field = wrapper
@@ -363,7 +503,7 @@ describe('IntegrationConnectorFormDrawer client form redesign', () => {
const code = wrapper.find('[data-testid="client-code"]');
expect((code.element as HTMLInputElement).disabled).toBe(true);
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务']);
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
const envOptions = wrapper.find('[data-testid="client-environment"]').findAll('option');
expect(envOptions.map((o) => o.text())).toEqual(['开发', '测试', '生产']);
});
@@ -7,10 +7,13 @@
客户端编码留空时按名称自动建议、
接口编码留空时按「客户端实例编码-名称」自动建议(均可手改,已填不覆盖,编辑态编码锁定);
客户端实例的连接器类型/环境/凭据引用均为下拉(选项来自模块常量与凭据列表,未知值兜底);
connector_type=database 时显示 db_kind 专属四选一下拉(必填校验在 composable 提交层),
endpoint label 按类型切换(REST=接口地址 / SOAP=WSDL / database=数据库连接串),切离 database 清空 db_kind;
接口定义的连接器类型随所选客户端实例联动只读展示(提交由后端以客户端为准推导);
绑定的客户端实例随所选接口定义联动带出并锁定(接口归属即客户端归属);
绑定的接口为有序步骤编辑器:添加/删除/上移下移,每步独立 param_mapping JSON,
步骤归属客户端以只读提示展示(client 由各步接口自带,表单不再单独维护);
绑定表单的能力下拉选项本地化为「中文名(注册名)」(未注册翻译兜底注册名);
接口与绑定的状态均为只读徽章(发布/退役走列表生命周期按钮),四个 JSON 契约字段常显不折叠;
接口与绑定的状态均为只读徽章(发布/退役走列表生命周期按钮),JSON 契约字段常显不折叠;
凭据引用:状态不进表单(由列表生命周期按钮流转);编辑态以「基本信息」只读信息区
展示编码/类型/来源/状态(label+值行,与接口定义只读字段同款式),新建态下拉选项
文案本地化与列表一致;高级配置帮助文案按连接器类型的生效键动态切换。
@@ -24,6 +27,7 @@ import JsonTextareaField from './JsonTextareaField.vue';
import {
CONNECTOR_CONFIG_KEYS,
CONNECTOR_TYPE_OPTIONS,
DB_KIND_OPTIONS,
ENVIRONMENT_OPTIONS,
suggestClientCode,
suggestInterfaceCode,
@@ -33,6 +37,7 @@ import type {
ClientInstanceFormState,
CredentialReferenceFormState,
InterfaceDefinitionFormState,
IntegrationConnectorType,
} from '../types/integration-connector.types';
const props = defineProps<{
@@ -43,9 +48,9 @@ const props = defineProps<{
bindingForm: BindingFormState;
credentialForm: CredentialReferenceFormState;
isSaving: boolean;
/** 客户端实例选项:connector_type 供接口表单联动展示连接器类型。 */
/** 客户端实例选项:connector_type 供接口表单联动展示连接器类型;name 供步骤 client 只读提示。 */
clientOptions: Array<{ code: string; name: string; connector_type?: string }>;
/** 接口定义选项:client_instance_code 供绑定表单联动带出客户端实例。 */
/** 接口定义选项:client_instance_code 供绑定步骤的归属客户端只读提示。 */
interfaceOptions: Array<{ code: string; name: string; client_instance_code?: string }>;
capabilityOptions: Array<{ name: string }>;
credentialTypeOptions: Array<{ type: string; fields: Array<{ key: string; secret: boolean; required: boolean }> }>;
@@ -103,6 +108,30 @@ function capabilityOptionLabel(name: string) {
return label === name ? name : `${label}(${name})`;
}
/**
* 切换客户端实例的连接器类型:非 database 类型清空 db_kind 残留值,
* 避免切走后旧值随保存提交(database 时 db_kind 必填,校验在 composable 提交层)。
*/
function onConnectorTypeChange() {
if (props.clientForm.connector_type !== 'database') {
props.clientForm.db_kind = '';
}
}
/** 连接地址 label 按类型切换:REST=接口地址 / SOAP=WSDL 地址 / database=数据库连接串。 */
const endpointLabelKey = computed(() => {
if (props.clientForm.connector_type === 'database') return 'admin.integrationConnector.endpointLabel.database';
if (props.clientForm.connector_type === 'soap') return 'admin.integrationConnector.fields.wsdl';
return 'admin.integrationConnector.fields.endpoint';
});
/** 连接地址占位符随 label 同步切换(示例格式按类型区分)。 */
const endpointPlaceholderKey = computed(() => {
if (props.clientForm.connector_type === 'database') return 'admin.integrationConnector.placeholders.database';
if (props.clientForm.connector_type === 'soap') return 'admin.integrationConnector.placeholders.wsdl';
return 'admin.integrationConnector.placeholders.endpoint';
});
/** 接口编码仍为空且已选客户端实例时,按「客户端编码-名称」补建议(已手填不覆盖)。 */
function suggestInterfaceCodeIfEmpty() {
const form = props.interfaceForm;
@@ -119,21 +148,45 @@ function onInterfaceNameBlur() {
/** 切换接口的客户端实例:联动展示其连接器类型(仅展示,提交由后端以客户端为准推导),并补编码建议。 */
function onInterfaceClientChange() {
const selected = props.clientOptions.find((item) => item.code === props.interfaceForm.client_instance_code);
if (selected?.connector_type === 'rest' || selected?.connector_type === 'soap') {
props.interfaceForm.connector_type = selected.connector_type;
const type = selected?.connector_type as IntegrationConnectorType | undefined;
if (type && CONNECTOR_TYPE_OPTIONS.some((opt) => opt.value === type)) {
props.interfaceForm.connector_type = type;
}
suggestInterfaceCodeIfEmpty();
}
// ---- 绑定有序步骤编辑器:接口从单选改为有序多选,client 由各步接口归属自带 ----
/** 添加步骤:追加到末尾(新步骤默认未选接口、空映射)。 */
function addBindingStep() {
props.bindingForm.steps.push({ interface_code: '', param_mapping_json: '' });
}
/** 删除指定步骤(按索引,删除后后续步骤序号自动前移)。 */
function removeBindingStep(index: number) {
props.bindingForm.steps.splice(index, 1);
}
/**
* 切换绑定的接口定义:联动带出其所属客户端实例并锁定(接口归属即客户端归属)。
* 后端创建/更新仍做成对校验(INTEGRATION.BINDING_PAIR_MISMATCH)兜底直连 API 的场景。
* 上移/下移指定步骤:delta=-1 上移、+1 下移;越界直接忽略(按钮层已禁用,双保险)。
*/
function onBindingInterfaceChange() {
const selected = props.interfaceOptions.find((item) => item.code === props.bindingForm.interface_definition_code);
if (selected?.client_instance_code) {
props.bindingForm.client_instance_code = selected.client_instance_code;
}
function moveBindingStep(index: number, delta: number) {
const target = index + delta;
const steps = props.bindingForm.steps;
if (target < 0 || target >= steps.length) return;
const [moved] = steps.splice(index, 1);
if (!moved) return;
steps.splice(target, 0, moved);
}
/** 步骤归属客户端只读提示:由接口定义归属唯一确定(跨步可不同客户端,如 database+soap)。 */
function bindingStepClientHint(index: number): string {
const step = props.bindingForm.steps[index];
const iface = props.interfaceOptions.find((item) => item.code === step?.interface_code);
if (!iface?.client_instance_code) return '';
const client = props.clientOptions.find((item) => item.code === iface.client_instance_code);
const clientLabel = client ? optionLabel(client.name, client.code) : iface.client_instance_code;
return t('admin.integrationConnector.bindingSteps.clientHint', { client: clientLabel });
}
/** 高级配置示例(JSON 属代码示例,不入 i18n——字面大括号会破坏 vue-i18n 消息编译)。 */
@@ -269,10 +322,18 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.connectorType') }}</label>
<select v-model="clientForm.connector_type" class="input-field text-sm" data-testid="client-connector-type">
<select v-model="clientForm.connector_type" class="input-field text-sm" data-testid="client-connector-type" @change="onConnectorTypeChange">
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
</select>
</div>
<div v-if="clientForm.connector_type === 'database'" class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.dbKind') }}</label>
<!-- db_kind 专属四选一(D16):仅 database 类型显示;未选提交由 composable 校验拦截 -->
<select v-model="clientForm.db_kind" class="input-field text-sm" data-testid="client-db-kind">
<option value="">—</option>
<option v-for="kind in DB_KIND_OPTIONS" :key="kind" :value="kind">{{ t(`admin.integrationConnector.connectorDbKind.${kind}`) }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.environment') }}</label>
<select v-model="clientForm.environment" class="input-field text-sm" data-testid="client-environment">
@@ -284,10 +345,10 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
<div class="space-y-4">
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.connection') }}</h4>
<!-- 连接地址:endpoint 合一字段;label 按连接器类型显示(REST=接口地址,SOAP=WSDL 地址) -->
<!-- 连接地址:endpoint 合一字段;label 按连接器类型显示(REST=接口地址,SOAP=WSDL 地址,database=数据库连接串) -->
<div class="space-y-1.5">
<label class="label-field">{{ clientForm.connector_type === 'soap' ? t('admin.integrationConnector.fields.wsdl') : t('admin.integrationConnector.fields.endpoint') }}</label>
<input v-model="clientForm.endpoint" type="text" class="input-field text-sm" :placeholder="t(clientForm.connector_type === 'soap' ? 'admin.integrationConnector.placeholders.wsdl' : 'admin.integrationConnector.placeholders.endpoint')" data-testid="client-endpoint" />
<label class="label-field">{{ t(endpointLabelKey) }}</label>
<input v-model="clientForm.endpoint" type="text" class="input-field text-sm" :placeholder="t(endpointPlaceholderKey)" data-testid="client-endpoint" />
</div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div class="space-y-1.5">
@@ -377,7 +438,7 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
</template>
<!-- 绑定:客户端实例随接口定义联动锁定;状态为只读徽章(发布/退役走列表生命周期按钮) -->
<!-- 绑定:接口为有序步骤编辑器(client 由各步接口归属自带);状态为只读徽章(发布/退役走列表生命周期按钮) -->
<template v-else-if="activeEntity === 'binding'">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div class="space-y-1.5">
@@ -392,20 +453,6 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
<option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env">{{ t(`admin.integrationConnector.envLabels.${env}`) }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.clientInstance') }}</label>
<!-- 已选接口定义即锁定:客户端实例由接口定义归属唯一确定,不可单独维护 -->
<select v-model="bindingForm.client_instance_code" class="input-field text-sm disabled:opacity-70" :disabled="Boolean(bindingForm.interface_definition_code)" data-testid="binding-client">
<option v-for="opt in clientOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
</select>
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.bindingClientHint') }}</p>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.interfaceDef') }}</label>
<select v-model="bindingForm.interface_definition_code" class="input-field text-sm" data-testid="binding-interface" @change="onBindingInterfaceChange">
<option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
</select>
</div>
<div class="space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.fields.mappingVersion') }}</label>
<input v-model.number="bindingForm.mapping_version" type="number" class="input-field text-sm" />
@@ -423,13 +470,69 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
<input v-model="bindingForm.effective_to" type="datetime-local" class="input-field text-sm" />
</div>
</div>
<!-- 有序步骤编辑器:提交时以 steps_json([{interface_code, param_mapping_json}])发送,
调用期按数组顺序执行;client 由各步接口归属自带 → 每步只读提示,不再单独维护 -->
<div class="space-y-3">
<div class="flex items-center justify-between gap-2">
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.bindingSteps.label') }}</h4>
<button type="button" class="btn-ghost text-xs" data-testid="binding-add-step" @click="addBindingStep">
+ {{ t('admin.integrationConnector.bindingSteps.add') }}
</button>
</div>
<p class="text-xs text-muted">{{ t('admin.integrationConnector.bindingSteps.hint') }}</p>
<div
v-for="(step, index) in bindingForm.steps"
:key="index"
class="space-y-2 rounded-lg border border-slate-200 px-3 py-2.5"
data-testid="binding-step-row"
>
<div class="flex items-end gap-2">
<span class="pb-2 text-xs font-bold text-muted">{{ index + 1 }}</span>
<div class="flex-1 space-y-1.5">
<label class="label-field">{{ t('admin.integrationConnector.bindingSteps.interface') }}</label>
<select v-model="step.interface_code" class="input-field text-sm" :data-testid="`binding-step-interface-${index}`">
<option value="">—</option>
<option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
</select>
</div>
<button
type="button"
class="btn-ghost text-xs"
:disabled="index === 0"
:title="t('admin.integrationConnector.bindingSteps.moveUp')"
:data-testid="`binding-step-up-${index}`"
@click="moveBindingStep(index, -1)"
>↑</button>
<button
type="button"
class="btn-ghost text-xs"
:disabled="index === bindingForm.steps.length - 1"
:title="t('admin.integrationConnector.bindingSteps.moveDown')"
:data-testid="`binding-step-down-${index}`"
@click="moveBindingStep(index, 1)"
>↓</button>
<button
type="button"
class="btn-ghost text-xs"
:title="t('admin.integrationConnector.bindingSteps.remove')"
:data-testid="`binding-step-remove-${index}`"
@click="removeBindingStep(index)"
>✕</button>
</div>
<p v-if="bindingStepClientHint(index)" class="text-xs text-muted" :data-testid="`binding-step-client-${index}`">
{{ bindingStepClientHint(index) }}
</p>
<JsonTextareaField
v-model="step.param_mapping_json"
:label="t('admin.integrationConnector.bindingSteps.paramMapping', { index: index + 1 })"
/>
</div>
</div>
<details class="rounded-lg border border-slate-200 px-3 py-2">
<summary class="cursor-pointer text-xs font-bold text-secondary">{{ t('admin.integrationConnector.advancedConfig') }}</summary>
<div class="mt-2 space-y-2">
<JsonTextareaField v-model="bindingForm.context_selector_json" :label="t('admin.integrationConnector.fields.contextSelector')" />
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.contextSelectorHint') }}</p>
<JsonTextareaField v-model="bindingForm.param_mapping_json" :label="t('admin.integrationConnector.fields.paramMapping')" />
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.paramMappingHint') }}</p>
</div>
</details>
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
@@ -76,7 +76,7 @@ describe('useIntegrationConnectorAdmin', () => {
c.clientForm.value.config_json = '{"headers":{"X-Tenant":"A"}}';
await c.saveActive();
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith({
code: 'erp-x', name: 'ERP X', connector_type: 'rest', environment: 'prod',
code: 'erp-x', name: 'ERP X', connector_type: 'rest', environment: 'prod', db_kind: null,
endpoint: 'https://x.invalid', timeout_seconds: 90,
config_json: { headers: { 'X-Tenant': 'A' } }, credential_ref_code: null, enabled: true,
});
@@ -85,7 +85,7 @@ describe('useIntegrationConnectorAdmin', () => {
it('编辑客户端实例:有 id 走 PUT', async () => {
const c = makeHarness();
c.openEditModal('client', {
id: 1, code: 'erp-x', name: 'old', connector_type: 'rest', environment: 'prod',
id: 1, code: 'erp-x', name: 'old', connector_type: 'rest', environment: 'prod', db_kind: null,
config_json: {}, credential_ref_code: null, enabled: true,
});
c.clientForm.value.name = 'new';
@@ -93,6 +93,34 @@ describe('useIntegrationConnectorAdmin', () => {
expect(api.updateIntegrationClientInstance).toHaveBeenCalled();
});
it('database 客户端:未选 db_kind 拦截不调 API;选择后 payload 携带 db_kind', async () => {
const c = makeHarness();
c.openCreateModal('client');
c.clientForm.value.code = 'erp-db';
c.clientForm.value.name = 'ERP Oracle';
c.clientForm.value.connector_type = 'database';
await c.saveActive();
expect(api.createIntegrationClientInstance).not.toHaveBeenCalled();
c.clientForm.value.db_kind = 'oracle';
c.clientForm.value.endpoint = '127.0.0.1:1521/ORCL';
await c.saveActive();
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith(
expect.objectContaining({ connector_type: 'database', db_kind: 'oracle', endpoint: '127.0.0.1:1521/ORCL' }),
);
});
it('非 database 客户端 payload 的 db_kind 为 null(不输明文,凭据走引用)', async () => {
const c = makeHarness();
c.openCreateModal('client');
c.clientForm.value.code = 'erp-x';
c.clientForm.value.name = 'ERP X';
await c.saveActive();
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith(
expect.objectContaining({ connector_type: 'rest', db_kind: null, credential_ref_code: null }),
);
});
it('非法 JSON 字段触发拦截且不调 API', async () => {
const c = makeHarness();
c.openCreateModal('client');
@@ -130,24 +158,63 @@ describe('useIntegrationConnectorAdmin', () => {
expect(api.createIntegrationClientInstance).not.toHaveBeenCalled();
});
it('绑定:必填校验与 POST payload(状态与来源快捷列不随表单提交)', async () => {
it('绑定:有序多步 payload 用 steps_json,不再发送旧单步顶层字段', async () => {
const c = makeHarness();
c.openCreateModal('binding');
c.bindingForm.value.capability = 'in_transit_transfer.query_inventory';
c.bindingForm.value.client_instance_code = 'CLI-A';
c.bindingForm.value.interface_definition_code = 'IF-A';
c.bindingForm.value.capability = 'in_transit_transfer.create_transfer';
c.bindingForm.value.steps = [
{ interface_code: 'IF-STAGE', param_mapping_json: '{"erp_org":{"expr":"external_org"}}' },
{ interface_code: 'IF-SUBMIT', param_mapping_json: '' },
];
await c.saveActive();
expect(api.createIntegrationBinding).toHaveBeenCalledWith({
capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
param_mapping_json: {},
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
steps_json: [
{ interface_code: 'IF-STAGE', param_mapping_json: { erp_org: { expr: 'external_org' } } },
{ interface_code: 'IF-SUBMIT', param_mapping_json: {} },
],
mapping_version: 1, priority: 0, environment: 'prod',
effective_from: null, effective_to: null,
});
const payload = api.createIntegrationBinding.mock.calls[0][0] as Record<string, unknown>;
// 状态走列表生命周期按钮;客户端实例随接口定义联动(仍随 payload 提交)
// 客户端由各步接口归属自带,旧单步字段与状态均不随表单提交
expect(payload).not.toHaveProperty('interface_definition_code');
expect(payload).not.toHaveProperty('param_mapping_json');
expect(payload).not.toHaveProperty('client_instance_code');
expect(payload).not.toHaveProperty('status');
expect(payload).not.toHaveProperty('context_source_code');
});
it('绑定:步骤缺接口定义或步骤列表为空 → 拦截不调 API', async () => {
const c = makeHarness();
c.openCreateModal('binding');
c.bindingForm.value.capability = 'in_transit_transfer.create_transfer';
c.bindingForm.value.steps = [{ interface_code: '', param_mapping_json: '' }];
await c.saveActive();
expect(api.createIntegrationBinding).not.toHaveBeenCalled();
c.bindingForm.value.steps = [];
await c.saveActive();
expect(api.createIntegrationBinding).not.toHaveBeenCalled();
});
it('编辑既有 steps_json 绑定:单步行回显为 steps 并仍以 steps_json 提交', async () => {
const c = makeHarness();
c.openEditModal('binding', {
id: 7, capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
steps_json: [{ interface_code: 'IF-A', param_mapping_json: { org: { expr: 'external_org' } } }],
param_mapping_json: { org: { expr: 'external_org' } },
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
mapping_version: 1, priority: 0, environment: 'prod',
effective_from: null, effective_to: null, status: 'draft',
});
expect(c.bindingForm.value.steps).toEqual([
{ interface_code: 'IF-A', param_mapping_json: '{\n "org": {\n "expr": "external_org"\n }\n}' },
]);
await c.saveActive();
expect(api.updateIntegrationBinding).toHaveBeenCalled();
const payload = api.updateIntegrationBinding.mock.calls[0][1] as Record<string, unknown>;
expect(Array.isArray(payload.steps_json)).toBe(true);
expect(payload).not.toHaveProperty('interface_definition_code');
expect(payload).not.toHaveProperty('param_mapping_json');
});
it('绑定生命周期:publish 调动作端点并刷新绑定列表', async () => {
@@ -156,6 +223,7 @@ describe('useIntegrationConnectorAdmin', () => {
api.listIntegrationBindings.mockResolvedValue([]);
c.bindings.value = [{
id: 7, capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
steps_json: [{ interface_code: 'IF-A', param_mapping_json: {} }],
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
mapping_version: 1, priority: 0, environment: 'prod',
effective_from: null, effective_to: null, status: 'draft',
@@ -5,8 +5,10 @@
* 依赖:integration-connector.api、types、useMessage、useI18n。
* 逻辑:各列表独立 loadAll;新增/编辑共用表单弹窗态(form.id 区分);客户端编码
* 可手改、留空按名称自动生成,接口定义编码留空按「客户端编码-名称」自动建议;
* 接口与绑定状态只经 change*Lifecycle 按钮流转(表单内只读徽章);绑定表单的
* 客户端实例随所选接口定义联动带出并锁定(接口归属即客户端归属);
* database 类型 db_kind 必填四选一(未选提交在前端拦截),非 database 恒为 null;
* 接口与绑定状态只经 change*Lifecycle 按钮流转(表单内只读徽章);绑定表单为
* 有序步骤编辑器(steps 数组),提交 payload 用 steps_json(每步 interface_code +
* param_mapping_json),client 由各步接口归属自带、不再发送旧单步顶层字段;
* 凭据状态只经列表行内开关流转(启用↔停用,表单不维护状态);
* 全部行内状态操作经 lifecycleBusy 互斥(进行中忽略新触发);接口/绑定退役
* 接近终态需 window.confirm 二次确认,可逆转移直达;
@@ -46,6 +48,7 @@ import {
createEmptyCredentialReferenceForm,
createEmptyInterfaceDefinitionForm,
credentialReferenceRowToForm,
DB_KIND_OPTIONS,
interfaceDefinitionRowToForm,
normalizeConnectionTestResponse,
suggestClientCode,
@@ -64,6 +67,9 @@ import {
type InterfaceDefinitionFormState,
} from '../types/integration-connector.types';
/** db_kind 四库枚举(D16);仅用于 DB_KIND_OPTIONS.includes 的类型收窄。 */
type DbKind = (typeof DB_KIND_OPTIONS)[number];
type EditableEntity = 'client' | 'interface' | 'binding' | 'credential';
/** 接口定义/绑定生命周期动作(与后端 CONFIG_STATUS_TRANSITIONS 一一对应)。 */
@@ -203,9 +209,15 @@ export function useIntegrationConnectorAdmin() {
msg.warning(t('admin.integrationConnector.msg.codeInvalid'));
return;
}
// database 类型 db_kind 必填(D16 四选一):未选在前端拦截,不发请求。
if (form.connector_type === 'database' && !DB_KIND_OPTIONS.includes(form.db_kind as DbKind)) {
msg.warning(t('admin.integrationConnector.msg.fillDbKind'));
return;
}
const configJson = parseJsonField(form.config_json, 'config_json');
const payload = {
code, name: form.name.trim(), connector_type: form.connector_type,
db_kind: form.connector_type === 'database' ? form.db_kind : null,
environment: form.environment,
endpoint: form.endpoint.trim() || null,
timeout_seconds: form.timeout_seconds.trim() ? Number(form.timeout_seconds) : null,
@@ -237,16 +249,27 @@ export function useIntegrationConnectorAdmin() {
else await createIntegrationInterfaceDefinition(payload);
} else if (activeEntity.value === 'binding') {
const form = bindingForm.value;
if (!form.capability.trim() || !form.client_instance_code.trim() || !form.interface_definition_code.trim()) {
// 有序多步:至少一步且每步必选接口;client 由各步接口归属自带(后端按接口推导),
// 不再发送旧单步顶层字段(interface_definition_code/param_mapping_json)。
if (!form.capability.trim() || form.steps.length === 0) {
msg.warning(t('admin.integrationConnector.msg.fillBinding'));
return;
}
// 客户端实例随所选接口定义联动带出(接口归属即客户端归属);
const steps: Array<{ interface_code: string; param_mapping_json: Record<string, unknown> }> = [];
for (const [index, step] of form.steps.entries()) {
if (!step.interface_code.trim()) {
msg.warning(t('admin.integrationConnector.msg.fillBinding'));
return;
}
steps.push({
interface_code: step.interface_code.trim(),
param_mapping_json: parseJsonField(step.param_mapping_json, `steps_json[${index}].param_mapping_json`),
});
}
// 状态不随表单提交:新建固定 draft,发布/退役走列表生命周期按钮。
const payload = {
capability: form.capability.trim(), context_selector_json: parseJsonField(form.context_selector_json, 'context_selector_json'),
param_mapping_json: parseJsonField(form.param_mapping_json, 'param_mapping_json'),
client_instance_code: form.client_instance_code.trim(), interface_definition_code: form.interface_definition_code.trim(),
steps_json: steps,
mapping_version: Number(form.mapping_version || 1), priority: Number(form.priority || 0),
environment: form.environment, effective_from: form.effective_from || null, effective_to: form.effective_to || null,
};
@@ -7,14 +7,18 @@
*/
/** 连接器类型:与后端 CONNECTOR_TYPES 对齐。 */
export type IntegrationConnectorType = 'rest' | 'soap';
export type IntegrationConnectorType = 'rest' | 'soap' | 'database';
/** 连接器类型选项(labelKey 为 i18n 键;新增类型在此追加一行并补四语言文案)。 */
export const CONNECTOR_TYPE_OPTIONS: ReadonlyArray<{ value: IntegrationConnectorType; labelKey: string }> = [
{ value: 'rest', labelKey: 'admin.integrationConnector.connectorTypes.rest' },
{ value: 'soap', labelKey: 'admin.integrationConnector.connectorTypes.soap' },
{ value: 'database', labelKey: 'admin.integrationConnector.connectorTypes.database' },
];
/** database 类型 db_kind 选项(与后端 D16 四库驱动注册表对齐;label 键 connectorDbKind.*)。 */
export const DB_KIND_OPTIONS = ['mysql', 'oracle', 'sqlserver', 'postgresql'] as const;
/** 环境选项(与发布流程 dev→test→prod 对齐;新增环境在此追加并补四语言文案)。 */
export const ENVIRONMENT_OPTIONS = ['dev', 'test', 'prod'] as const;
@@ -22,6 +26,7 @@ export const ENVIRONMENT_OPTIONS = ['dev', 'test', 'prod'] as const;
export const CONNECTOR_CONFIG_KEYS: Readonly<Record<string, ReadonlyArray<string>>> = {
rest: ['headers'],
soap: [],
database: ['oracle_lib_dir'],
};
/** 客户端编码规则:小写字母/数字开头,仅小写字母、数字、连字符(保存后不可改)。 */
@@ -135,6 +140,8 @@ export interface IntegrationClientInstanceRow {
environment: string;
endpoint: string | null;
timeout_seconds: number | null;
/** database 类型专列(D16 四库);rest/soap 为 null。 */
db_kind: string | null;
config_json: Record<string, unknown>;
credential_ref_code: string | null;
enabled: boolean;
@@ -158,11 +165,18 @@ export interface IntegrationInterfaceDefinitionRow {
enabled: boolean;
}
/** 绑定(能力 → 客户端 + 接口 + 映射版本)。 */
/** 绑定有序步骤(调用期按序执行;客户端实例由步骤接口归属自带)。 */
export interface IntegrationBindingStep {
interface_code: string;
param_mapping_json: Record<string, unknown>;
}
/** 绑定(能力 → 有序多步接口配方 + 映射版本;旧单步列为 P2 删前镜像,仅回显兜底)。 */
export interface IntegrationBindingRow {
id: number;
capability: string;
context_selector_json: Record<string, unknown>;
steps_json: IntegrationBindingStep[];
param_mapping_json: Record<string, unknown>;
client_instance_code: string;
interface_definition_code: string;
@@ -195,6 +209,8 @@ export interface ClientInstanceFormState {
code: string;
name: string;
connector_type: IntegrationConnectorType;
/** database 类型专属四选一(mysql/oracle/sqlserver/postgresql);非 database 恒为空串。 */
db_kind: string;
environment: string;
endpoint: string;
timeout_seconds: string;
@@ -224,17 +240,24 @@ export interface InterfaceDefinitionFormState {
}
/**
* 绑定表单(JSON 字段以文本承载,提交时解析)。
* client_instance_code 随所选接口定义联动带出并锁定(接口归属即客户端归属),仍随表单提交;
* status 仅作徽章展示:新建固定 draft,发布/退役经列表生命周期按钮流转,均不随表单提交。
* 绑定表单步骤(JSON 映射以文本承载,提交时解析;每步独立编辑)。
*/
export interface BindingStepFormState {
interface_code: string;
param_mapping_json: string;
}
/**
* 绑定表单(接口为有序多步,client 由各步接口归属自带 → 不再单独维护)。
* JSON 字段以文本承载,提交时解析;status 仅作徽章展示:新建固定 draft,
* 发布/退役经列表生命周期按钮流转,均不随表单提交。
*/
export interface BindingFormState {
id: number | null;
capability: string;
context_selector_json: string;
param_mapping_json: string;
client_instance_code: string;
interface_definition_code: string;
/** 有序步骤(调用期按数组顺序执行;至少一步且每步必选接口才能提交)。 */
steps: BindingStepFormState[];
mapping_version: number;
priority: number;
environment: string;
@@ -266,6 +289,7 @@ export function createEmptyClientInstanceForm(): ClientInstanceFormState {
code: '',
name: '',
connector_type: 'rest',
db_kind: '',
environment: 'prod',
endpoint: '',
timeout_seconds: '60',
@@ -282,6 +306,7 @@ export function clientInstanceRowToForm(row: IntegrationClientInstanceRow): Clie
code: row.code,
name: row.name,
connector_type: row.connector_type,
db_kind: row.db_kind ?? '',
environment: row.environment,
endpoint: row.endpoint ?? '',
timeout_seconds: String(row.timeout_seconds ?? ''),
@@ -327,15 +352,13 @@ export function interfaceDefinitionRowToForm(row: IntegrationInterfaceDefinition
};
}
/** 创建空的绑定表单。 */
/** 创建空的绑定表单(空步骤列表,用户经「添加步骤」构建有序配方)。 */
export function createEmptyBindingForm(): BindingFormState {
return {
id: null,
capability: '',
context_selector_json: '',
param_mapping_json: '',
client_instance_code: '',
interface_definition_code: '',
steps: [],
mapping_version: 1,
priority: 0,
environment: 'prod',
@@ -345,15 +368,24 @@ export function createEmptyBindingForm(): BindingFormState {
};
}
/** 列表行回填为绑定编辑表单(status 仅回显,不随保存提交)。 */
/**
* 列表行回填为绑定编辑表单(status 仅回显,不随保存提交)。
* 步骤优先读 steps_json;steps_json 为空(P2 前的存量旧列行)时由旧单步列合成一步兜底。
*/
export function bindingRowToForm(row: IntegrationBindingRow): BindingFormState {
const rawSteps = row.steps_json?.length
? row.steps_json
: [{ interface_code: row.interface_definition_code, param_mapping_json: row.param_mapping_json || {} }];
return {
id: row.id,
capability: row.capability,
context_selector_json: toJsonText(row.context_selector_json),
param_mapping_json: toJsonText(row.param_mapping_json),
client_instance_code: row.client_instance_code,
interface_definition_code: row.interface_definition_code,
steps: rawSteps
.filter((step) => step.interface_code)
.map((step) => ({
interface_code: step.interface_code,
param_mapping_json: toJsonText(step.param_mapping_json),
})),
mapping_version: Number(row.mapping_version || 1),
priority: Number(row.priority || 0),
environment: row.environment,
@@ -388,3 +420,71 @@ export function credentialReferenceRowToForm(row: IntegrationCredentialReference
status: row.status,
};
}
/** 集成调用日志行(GET /calls 列表项;字段全部能力无关通用口径)。 */
export interface IntegrationCallLogRow {
id: number;
created_at: string | null;
capability: string;
operation_id: string;
trace_id: string;
status: string;
elapsed_ms: number;
business_ref: string | null;
client_code: string | null;
interface_code: string | null;
connector_type: string | null;
step_index: number | null;
step_count: number | null;
}
/** 线级事实(按连接类型二选一;database=SQL/绑定/行数,soap/rest=HTTP 往返)。 */
export interface IntegrationCallWire {
kind: 'database' | 'soap' | 'rest';
statements?: { phase: string; sql: string; binds: Record<string, unknown>; rowcount?: number; row_count?: number }[];
rowcount?: number;
rows?: unknown[];
method?: string;
url?: string;
soap_action?: string;
headers?: string;
request_body?: string;
http_status?: number;
response_body?: string;
}
/** 调用全量详情(GET /calls/{id};含同 operation_id 步骤时间线)。 */
export interface IntegrationCallDetail {
call: {
id: number;
created_at: string | null;
capability: string;
operation_id: string;
trace_id: string;
status: string;
elapsed_ms: number;
business_ref: string | null;
binding_snapshot_json: Record<string, unknown>;
request_summary_json: Record<string, unknown>;
response_summary_json: Record<string, unknown>;
wire_json: IntegrationCallWire | null;
};
timeline: { id: number; step_index: number | null; step_count: number | null; interface_code: string | null; status: string; elapsed_ms: number }[];
}
/** 列表查询条件(全部可选;后端缺省口径 page=1/page_size=20)。 */
export interface IntegrationCallFilters {
capability?: string;
interface_code?: string;
client_code?: string;
connector_type?: string;
status?: string;
operation_id?: string;
trace_id?: string;
keyword?: string;
business_ref?: string;
date_from?: string;
date_to?: string;
page?: number;
page_size?: number;
}
@@ -0,0 +1,107 @@
/**
* features/admin/modules/integration-connector/utils/integration-call-replay.spec.ts
* 验证调用复现命令生成:soap/rest curl 组装(SOAPAction 引号、headers 展开、凭据脱敏)、
* inlineBinds 具名绑定内联(单引号转义)、buildSqlReplay 写入类自动包事务 + ROLLBACK 警示。
*/
import { describe, expect, it } from 'vitest';
import { buildCurl, buildSqlReplay, inlineBinds } from './integration-call-replay';
import type { IntegrationCallWire } from '../types/integration-connector.types';
describe('buildCurl(soap)', () => {
it('含 Content-Type、SOAPAction(保留双引号)与 --data-binary 完整 body', () => {
// [断言意图] SOAPAction 值按真实 ERP 口径自带双引号,生成命令必须原样保留且整体 shell 安全包裹
const wire: IntegrationCallWire = {
kind: 'soap',
method: 'POST',
url: 'http://erp.example/TopGP.asmx',
soap_action: '"urn:CreateTransfer"',
request_body: '<soapenv:Envelope>…</soapenv:Envelope>',
};
const cmd = buildCurl(wire);
expect(cmd).toContain('curl -X POST');
expect(cmd).toContain("-H 'SOAPAction: \"urn:CreateTransfer\"'");
expect(cmd).toContain("-H 'Content-Type: text/xml; charset=utf-8'");
expect(cmd).toContain('--data-binary');
expect(cmd).toContain('<soapenv:Envelope>…</soapenv:Envelope>');
// [断言意图] 末行不得以续行符 \ 结尾,否则粘贴进 bash 会进入 PS2 续行等待
expect(cmd.endsWith('\\')).toBe(false);
});
it('soap_action 缺省时回退空双引号', () => {
const cmd = buildCurl({ kind: 'soap', url: 'http://erp.example/svc' });
expect(cmd).toContain('SOAPAction: ""');
expect(cmd.endsWith('\\')).toBe(false);
});
});
describe('buildCurl(rest)', () => {
it('headers JSON 逐个展开为 -H,凭据位 *** 替换为 ***REDACTED***', () => {
// [断言意图] 脱敏口径:wire 中凭据位只存 '***',复现命令不得还原真实凭据
const wire: IntegrationCallWire = {
kind: 'rest',
method: 'POST',
url: 'https://api.example/v1/orders',
headers: JSON.stringify({ 'Content-Type': 'application/json', Authorization: '***', 'X-App-Id': 'demo' }),
request_body: '{"doc_no":"TGHX1-OR-00001"}',
};
const cmd = buildCurl(wire);
expect(cmd).toContain("-H 'Content-Type: application/json'");
expect(cmd).toContain("-H 'Authorization: ***REDACTED***'");
expect(cmd).toContain("-H 'X-App-Id: demo'");
expect(cmd).toContain('-d');
expect(cmd).toContain('{"doc_no":"TGHX1-OR-00001"}');
// [断言意图] 末行不得以续行符 \ 结尾(修复前 -d 段恒带尾随 \,bash 粘贴会挂起)
expect(cmd.endsWith('\\')).toBe(false);
});
it('无 headers 无 body 时为单行命令且不以续行符收尾', () => {
// [断言意图] 回归:修复前即使裸命令也以 \ 收尾(filter 后末段仍是带 \ 的首行)
const cmd = buildCurl({ kind: 'rest', method: 'GET', url: 'https://api.example/ping' });
expect(cmd).toContain("curl -X GET 'https://api.example/ping'");
expect(cmd.endsWith('\\')).toBe(false);
expect(cmd.split('\n')).toHaveLength(1);
});
});
describe('inlineBinds', () => {
it("字符串绑定单引号转义(it doesn't → doesn''t),数字原样,未知占位符保留", () => {
// [断言意图] 单引号必须转义为 '',否则复现 SQL 直接语法报错
const sql = "UPDATE t SET note = :note, qty = :qty WHERE id = :id";
const out = inlineBinds(sql, { note: "it doesn't", qty: 3, id: 7 });
expect(out).toContain("'it doesn''t'");
expect(out).toContain('qty = 3');
expect(out).toContain('id = 7');
const unknown = inlineBinds('SELECT :missing FROM dual', {});
expect(unknown).toContain(':missing');
});
});
describe('buildSqlReplay(写入类)', () => {
it('INSERT 语句包 BEGIN; … ROLLBACK; 事务并带环境确认警示;bulk 段注释取首行口径', () => {
// [断言意图] 写入类复现默认 ROLLBACK 兜底,防止误写目标库;确认后人工改 COMMIT
const wire: IntegrationCallWire = {
kind: 'database',
statements: [
{ phase: 'pre', sql: "INSERT INTO t (a) VALUES (:a)", binds: { a: "O'Brien" } },
{ phase: 'bulk', sql: 'UPDATE t SET b = :b', binds: { b: 'x' } },
],
};
const out = buildSqlReplay(wire);
expect(out).toContain('⚠ 写入语句');
expect(out).toContain('BEGIN;');
expect(out).toContain('ROLLBACK');
expect(out).toContain("O''Brien");
expect(out).toContain('-- bulk(绑定取首行;全量行由应用逐行 executemany)');
});
it('只读 SELECT 不包事务,直接以分号收尾', () => {
const out = buildSqlReplay({
kind: 'database',
statements: [{ phase: 'read', sql: 'SELECT * FROM t WHERE id = :id', binds: { id: 1 } }],
});
expect(out).not.toContain('BEGIN;');
expect(out).not.toContain('ROLLBACK');
expect(out).toContain('id = 1');
});
});
@@ -0,0 +1,95 @@
/**
* features/admin/modules/integration-connector/utils/integration-call-replay.ts
* 集成调用复现命令生成(wire → 外部工具可直接执行的文本)。
* 依赖:../types/integration-connector.types(IntegrationCallWire 线级事实类型)。
* 逻辑:soap/rest 生成 curl(凭据位为 ***REDACTED***,需手工替换);
* database 生成绑定已内联的 SQL(写入类包事务并标注警示)。
* 供 IntegrationCallLogsPanel 抽屉「复制 curl / 复制 SQL」按钮消费。
*/
import type { IntegrationCallWire } from '../types/integration-connector.types';
const REDACTED = '***REDACTED***';
/** shell 单引号安全包裹(' → '\'' ),保证含单引号的 body/URL 可原样粘贴执行。 */
function shellQuote(value: string): string {
return `'${value.replace(/'/g, `'\\''`)}'`;
}
/**
* 拼接 curl 多行命令并剥离末段尾随续行符。
* 约束:末行若以 `\` 结尾,粘贴进 bash 会进入 PS2 续行等待,破坏「可直接执行」承诺;
* 末段内容本身恒以引号收尾,结尾的 ` \` 只可能是我们追加的续行符,不会误伤。
*/
function joinCurlCommand(lines: string[]): string {
return lines.filter(Boolean).join('\n').replace(/ \\$/, '');
}
/**
* 生成 HTTP 调用的 curl 复现命令。
* soap 固定 text/xml + SOAPAction 头(值为空时回退 '""');rest 展开 headers JSON
* (值为 '***' 的凭据位替换为 ***REDACTED*** 提示手工替换)。
* @param wire - 调用详情 wire_json(kind 必须为 soap/rest,database 走 buildSqlReplay)
* @returns 多行 curl 命令文本(\ 续行,可直接粘贴 bash,末行不以 \ 结尾)
*/
export function buildCurl(wire: IntegrationCallWire): string {
if (wire.kind === 'soap') {
return joinCurlCommand([
`curl -X ${wire.method || 'POST'} ${shellQuote(wire.url || '')} \\`,
` -H 'Content-Type: text/xml; charset=utf-8' \\`,
` -H ${shellQuote(`SOAPAction: ${wire.soap_action || '""'}`)} \\`,
` --data-binary ${shellQuote(wire.request_body || '')}`,
]);
}
const headers = wire.headers
? (JSON.parse(wire.headers) as Record<string, string>)
: {};
const headerLines = Object.entries(headers)
.map(([k, v]) => ` -H ${shellQuote(`${k}: ${v === '***' ? REDACTED : v}`)} \\`)
.join('\n');
const bodyPart = wire.request_body
? ` -d ${shellQuote(wire.request_body)} \\`
: '';
return joinCurlCommand([
`curl -X ${wire.method || 'GET'} ${shellQuote(wire.url || '')} \\`,
headerLines,
bodyPart,
]);
}
/**
* SQL 字面量引价:null/undefined → NULL,数字原样,字符串单引号包裹且内部 ' 转义为 ''。
* @param value - 绑定值(来自 wire statements[].binds,任意 JSON 类型)
*/
function quoteLiteral(value: unknown): string {
if (value === null || value === undefined) return 'NULL';
if (typeof value === 'number') return String(value);
return `'${String(value).replace(/'/g, "''")}'`;
}
/**
* 把具名绑定(:name)内联为 SQL 字面量,生成绑定已内联的可执行版 SQL。
* @param sql - 含 :name 占位符的原始 SQL(无对应绑定的占位符原样保留,不静默改写)
* @param binds - 绑定字典(可为空对象)
*/
export function inlineBinds(sql: string, binds: Record<string, unknown>): string {
return sql.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g, (raw, name: string) =>
name in binds ? quoteLiteral(binds[name]) : raw);
}
/**
* 生成 database 类型调用的 SQL 复现文本。
* bulk 段绑定取首行并注明全量行由应用 executemany;任一语句为写入类
* (INSERT/UPDATE/DELETE/MERGE,大小写不敏感)时包 BEGIN; ... ROLLBACK; 事务并加红字警示,
* 防止复现时误写目标库。
* @param wire - 调用详情 wire_json(kind 必须为 database)
* @returns 可执行 SQL 文本(写入类默认 ROLLBACK,确认后手工改 COMMIT)
*/
export function buildSqlReplay(wire: IntegrationCallWire): string {
const statements = (wire.statements || [])
.map((s) => (s.phase === 'bulk'
? `-- bulk(绑定取首行;全量行由应用逐行 executemany)\n${inlineBinds(s.sql, s.binds || {})}`
: inlineBinds(s.sql, s.binds || {})));
const isWrite = statements.some((s) => /^\s*(INSERT|UPDATE|DELETE|MERGE)/im.test(s));
const body = statements.join(';\n\n');
return isWrite ? `-- ⚠ 写入语句:请确认目标环境后再执行\nBEGIN;\n${body};\nROLLBACK; -- 确认后改为 COMMIT` : `${body};`;
}
+72 -8
View File
@@ -5161,7 +5161,8 @@
"interface": "Interface Definitions",
"binding": "Bindings",
"credential": "Credential References",
"capability": "Capabilities"
"capability": "Capabilities",
"calls": "Call logs"
},
"statusLabels": {
"draft": "Draft",
@@ -5212,7 +5213,7 @@
"environment": "Environment",
"status": "Status",
"clientInstance": "Client Instance",
"interfaceDef": "Interface",
"interfaceDef": "Interface Steps (ordered)",
"secretRef": "Secret Reference",
"secretProvider": "Source",
"account": "Account",
@@ -5227,6 +5228,7 @@
"code": "Code",
"name": "Name",
"connectorType": "Connector Type",
"dbKind": "Database kind (db_kind)",
"environment": "Environment",
"credentialRef": "Credential Reference Code",
"configJson": "Connection Config JSON (endpoint / timeout / default org, etc.)",
@@ -5248,9 +5250,6 @@
"effectiveTo": "Effective To",
"contextSelector": "Advanced Routing Conditions JSON",
"contextSelectorHint": "All key-value pairs must be contained in the call context to match; callers currently send no routing context, so leave it empty for the default binding.",
"paramMapping": "Parameter Mapping JSON",
"paramMappingHint": "Translation rules from domain params to interface params (e.g. erp_org to organization, condition template); leave empty for same-name passthrough.",
"bindingClientHint": "Derived and locked from the selected interface definition; not editable separately.",
"secretRef": "Secret Reference Key",
"secretProvider": "Secret Source",
"credentialType": "Credential Type",
@@ -5278,7 +5277,8 @@
"msg": {
"fillClient": "Please fill in the name",
"fillInterface": "Please select a client instance (the code can be auto-generated)",
"fillBinding": "Please fill in the capability, client instance and interface definition",
"fillBinding": "Please fill in the capability and add at least one step (choose an interface per step)",
"fillDbKind": "Please choose a database kind (MySQL / Oracle / SQL Server / PostgreSQL)",
"fillCredential": "Please fill in the code and the secret reference",
"fillCredentialDb": "Please fill in the code and the required credential fields: {fields}",
"credentialTypeMissing": "Credential type list not loaded, please refresh and retry",
@@ -5313,7 +5313,8 @@
"endpoint": "https://erp-api.example.com/ws",
"wsdl": "https://erp-api.example.com/wsdl",
"requestPath": "Path supports placeholders, e.g. /transfer/xxx",
"passwordKeep": "Leave blank to keep the current password"
"passwordKeep": "Leave blank to keep the current password",
"database": "erp-host:1521/ORCL or 127.0.0.1:3306/dbname"
},
"advancedConfig": "Advanced Config (JSON)",
"formatJson": "Format",
@@ -5334,7 +5335,70 @@
},
"connectorTypes": {
"rest": "REST API",
"soap": "SOAP Service"
"soap": "SOAP Service",
"database": "Database (Direct)"
},
"connectorDbKind": {
"mysql": "MySQL",
"oracle": "Oracle",
"sqlserver": "SQL Server",
"postgresql": "PostgreSQL"
},
"endpointLabel": {
"database": "Database connection string (host:port/service or /database)"
},
"bindingSteps": {
"label": "Execution Steps (ordered)",
"add": "Add Step",
"remove": "Remove Step",
"moveUp": "Move Up",
"moveDown": "Move Down",
"interface": "Interface Definition",
"paramMapping": "Step {index} Parameter Mapping JSON",
"clientHint": "Client instance is derived from this step's interface: {client}",
"hint": "Steps run in array order; each step has its own parameter mapping, and the client instance comes with each step's interface."
},
"callLogs": {
"title": "Call records",
"filterInterface": "Interface",
"filterClient": "Client code",
"filterConnector": "Connector type",
"filterStatus": "Status",
"filterOperationId": "Operation ID",
"filterTraceId": "Trace ID",
"filterBusinessRef": "Business ref",
"filterKeyword": "Keyword in request",
"dateFrom": "Time from",
"dateTo": "Time to",
"query": "Query",
"reset": "Reset",
"colTime": "Time",
"colCapability": "Capability",
"colInterface": "Interface",
"colRef": "Ref",
"colStep": "Step",
"colStatus": "Status",
"colElapsed": "Elapsed",
"detailTitle": "Call detail",
"timeline": "Step timeline",
"request": "Request",
"response": "Response",
"wire": "Wire-level request",
"rawPayload": "Raw payload",
"normalized": "Business params (normalized)",
"normalizedJson": "Normalized JSON",
"copyBody": "Copy body",
"copyCurl": "Copy curl",
"copySql": "Copy SQL",
"copyRaw": "Copy raw payload",
"copyJson": "Copy JSON",
"copyOperationId": "Copy operation_id",
"copyTraceId": "Copy trace_id",
"copied": "Copied",
"noWire": "No wire details (historical record)",
"sqlWriteWarning": "⚠ Write statements: confirm target environment before executing",
"prevPage": "Previous page",
"nextPage": "Next page"
}
}
}
+72 -8
View File
@@ -5030,7 +5030,8 @@
"interface": "นิยามอินเทอร์เฟซ",
"binding": "การผูก",
"credential": "การอ้างอิงข้อมูลรับรอง",
"capability": "รายการความสามารถ"
"capability": "รายการความสามารถ",
"calls": "ประวัติการเรียกใช้"
},
"statusLabels": {
"draft": "ฉบับร่าง",
@@ -5081,7 +5082,7 @@
"environment": "สภาพแวดล้อม",
"status": "สถานะ",
"clientInstance": "อินสแตนซ์ไคลเอ็นต์",
"interfaceDef": "อินเทอร์เฟซ",
"interfaceDef": "ขั้นตอนอินเทอร์เฟซ (เรียงลำดับ)",
"secretRef": "การอ้างอิง Secret",
"secretProvider": "แหล่งที่มา",
"account": "บัญชี",
@@ -5096,6 +5097,7 @@
"code": "รหัส",
"name": "ชื่อ",
"connectorType": "ประเภทตัวเชื่อมต่อ",
"dbKind": "ชนิดฐานข้อมูล (db_kind)",
"environment": "สภาพแวดล้อม",
"credentialRef": "รหัสการอ้างอิงข้อมูลรับรอง",
"configJson": "JSON การตั้งค่าการเชื่อมต่อ (ที่อยู่/หมดเวลา/org เริ่มต้น ฯลฯ)",
@@ -5117,9 +5119,6 @@
"effectiveTo": "มีผลถึง",
"contextSelector": "JSON เงื่อนไขการกำหนดเส้นทางขั้นสูง",
"contextSelectorHint": "คู่คีย์-ค่าทั้งหมดต้องอยู่ในบริบทการเรียกจึงจะจับคู่ได้ โดยเวอร์ชันปัจจุบันผู้เรียกไม่ส่งบริบทการกำหนดเส้นทาง ปล่อยว่างไว้จะเป็นการผูกค่าเริ่มต้น",
"paramMapping": "JSON การแมปพารามิเตอร์",
"paramMappingHint": "กฎการแปลพารามิเตอร์โดเมนเป็นพารามิเตอร์อินเทอร์เฟซ (เช่น erp_org เป็น organization, เทมเพลต condition) หากว่างจะส่งต่อชื่อเดียวกัน",
"bindingClientHint": "ดึงและล็อกโดยอัตโนมัติตามคำนิยามอินเทอร์เฟซที่เลือก แก้ไขเองไม่ได้",
"secretRef": "คีย์อ้างอิง Secret",
"secretProvider": "แหล่ง Secret",
"credentialType": "ประเภทข้อมูลรับรอง",
@@ -5147,7 +5146,8 @@
"msg": {
"fillClient": "กรุณากรอกชื่อ",
"fillInterface": "กรุณาเลือกอินสแตนซ์ไคลเอ็นต์ (รหัสสร้างอัตโนมัติได้)",
"fillBinding": "กรุณากรอกความสามารถ อินสแตนซ์ไคลเอ็นต์ และนิยามอินเทอร์เฟซ",
"fillBinding": "กรุณากรอกความสามารถ และเพิ่มขั้นตอนอย่างน้อยหนึ่งขั้น (เลือกอินเทอร์เฟซของแต่ละขั้น)",
"fillDbKind": "กรุณาเลือกชนิดฐานข้อมูล (MySQL / Oracle / SQL Server / PostgreSQL)",
"fillCredential": "กรุณากรอกรหัสและการอ้างอิง Secret",
"fillCredentialDb": "กรุณากรอกรหัส และฟิลด์ข้อมูลประจำตัวที่จำเป็น: {fields}",
"credentialTypeMissing": "รายการประเภทข้อมูลประจำตัวยังไม่โหลด โปรดรีเฟรชแล้วลองใหม่",
@@ -5182,7 +5182,8 @@
"endpoint": "https://erp-api.example.com/ws",
"wsdl": "https://erp-api.example.com/wsdl",
"requestPath": "เส้นทางรองรับตัวยึดตำแหน่ง เช่น /transfer/xxx",
"passwordKeep": "ปล่อยว่างไว้เพื่อคงรหัสผ่านเดิม"
"passwordKeep": "ปล่อยว่างไว้เพื่อคงรหัสผ่านเดิม",
"database": "erp-host:1521/ORCL หรือ 127.0.0.1:3306/dbname"
},
"advancedConfig": "การตั้งค่าขั้นสูง (JSON)",
"formatJson": "จัดรูปแบบ",
@@ -5203,7 +5204,70 @@
},
"connectorTypes": {
"rest": "REST API",
"soap": "บริการ SOAP"
"soap": "บริการ SOAP",
"database": "ฐานข้อมูล (เชื่อมตรง)"
},
"connectorDbKind": {
"mysql": "MySQL",
"oracle": "Oracle",
"sqlserver": "SQL Server",
"postgresql": "PostgreSQL"
},
"endpointLabel": {
"database": "สตริงการเชื่อมต่อฐานข้อมูล (host:port/service หรือ /database)"
},
"bindingSteps": {
"label": "ขั้นตอนการทำงาน (ตามลำดับ)",
"add": "เพิ่มขั้นตอน",
"remove": "ลบขั้นตอน",
"moveUp": "ย้ายขึ้น",
"moveDown": "ย้ายลง",
"interface": "นิยามอินเทอร์เฟซ",
"paramMapping": "JSON การแมปพารามิเตอร์ของขั้นตอนที่ {index}",
"clientHint": "อินสแตนซ์ไคลเอ็นต์กำหนดอัตโนมัติจากอินเทอร์เฟซของขั้นตอนนี้: {client}",
"hint": "ขั้นตอนจะทำงานตามลำดับในอาร์เรย์ แต่ละขั้นตอนมีการแมปพารามิเตอร์ของตัวเอง และอินสแตนซ์ไคลเอ็นต์มาพร้อมกับอินเทอร์เฟซของแต่ละขั้นตอน"
},
"callLogs": {
"title": "บันทึกการเรียกใช้",
"filterInterface": "รหัสอินเทอร์เฟซ",
"filterClient": "รหัสไคลเอ็นต์",
"filterConnector": "ประเภทตัวเชื่อมต่อ",
"filterStatus": "สถานะ",
"filterOperationId": "operation_id",
"filterTraceId": "trace_id",
"filterBusinessRef": "เลขที่เอกสารธุรกิจ",
"filterKeyword": "คำสำคัญในคำขอ",
"dateFrom": "เวลาเริ่มต้น",
"dateTo": "เวลาสิ้นสุด",
"query": "ค้นหา",
"reset": "รีเซ็ต",
"colTime": "เวลา",
"colCapability": "ความสามารถ",
"colInterface": "อินเทอร์เฟซ",
"colRef": "เลขที่อ้างอิง",
"colStep": "ขั้นตอน",
"colStatus": "สถานะ",
"colElapsed": "เวลาที่ใช้",
"detailTitle": "รายละเอียดการเรียกใช้",
"timeline": "ไทม์ไลน์ขั้นตอน",
"request": "คำขอ",
"response": "การตอบกลับ",
"wire": "คำขอระดับ wire",
"rawPayload": "ข้อความดิบ",
"normalized": "พารามิเตอร์ธุรกิจ (มาตรฐาน)",
"normalizedJson": "JSON มาตรฐาน",
"copyBody": "คัดลอก body",
"copyCurl": "คัดลอก curl",
"copySql": "คัดลอก SQL",
"copyRaw": "คัดลอกข้อความดิบ",
"copyJson": "คัดลอก JSON",
"copyOperationId": "คัดลอก operation_id",
"copyTraceId": "คัดลอก trace_id",
"copied": "คัดลอกแล้ว",
"noWire": "ไม่มีรายละเอียดระดับ wire (ระเบียนเก่า)",
"sqlWriteWarning": "⚠ คำสั่งเขียน: โปรดยืนยันสภาพแวดล้อมเป้าหมายก่อนดำเนินการ",
"prevPage": "หน้าก่อนหน้า",
"nextPage": "หน้าถัดไป"
}
}
}
+72 -8
View File
@@ -5188,7 +5188,8 @@
"interface": "接口定义",
"binding": "绑定",
"credential": "凭据引用",
"capability": "能力清单"
"capability": "能力清单",
"calls": "调用日志"
},
"statusLabels": {
"draft": "草稿",
@@ -5239,7 +5240,7 @@
"environment": "环境",
"status": "状态",
"clientInstance": "客户端实例",
"interfaceDef": "接口定义",
"interfaceDef": "接口步骤(有序)",
"secretRef": "Secret 引用",
"secretProvider": "来源",
"account": "账号",
@@ -5254,6 +5255,7 @@
"code": "编码",
"name": "名称",
"connectorType": "连接器类型",
"dbKind": "数据库类型(db_kind)",
"environment": "环境",
"credentialRef": "凭据引用编码",
"configJson": "连接配置 JSON(接口地址/超时/默认 org 等)",
@@ -5275,9 +5277,6 @@
"effectiveTo": "生效结束",
"contextSelector": "高级路由条件 JSON",
"contextSelectorHint": "键值对须全部包含于调用上下文才会命中;当前版本调用方不传路由上下文,留空即为默认绑定。",
"paramMapping": "参数映射 JSON",
"paramMappingHint": "域参数到接口参数的翻译规则(如 erp_org→organization、condition 模板);留空=同名直通。",
"bindingClientHint": "随所选接口定义自动带出并锁定,不可单独修改。",
"secretRef": "Secret 引用键",
"secretProvider": "Secret 来源",
"credentialType": "凭据类型",
@@ -5305,7 +5304,8 @@
"msg": {
"fillClient": "请填写名称",
"fillInterface": "请选择客户端实例(编码可自动生成)",
"fillBinding": "请填写能力、客户端实例与接口定义",
"fillBinding": "请填写能力,并至少添加一个步骤(每步选择接口定义)",
"fillDbKind": "请选择数据库类型(MySQL / Oracle / SQL Server / PostgreSQL)",
"fillCredential": "请填写编码与 Secret 引用",
"fillCredentialDb": "请填写编码,以及必填凭据字段:{fields}",
"credentialTypeMissing": "凭据类型清单未加载,请刷新页面后重试",
@@ -5340,7 +5340,8 @@
"endpoint": "https://erp-api.example.com/ws",
"wsdl": "https://erp-api.example.com/wsdl",
"requestPath": "路径支持占位符,如 /transfer/xxx",
"passwordKeep": "留空则保持原密码不变"
"passwordKeep": "留空则保持原密码不变",
"database": "erp-host:1521/ORCL 或 127.0.0.1:3306/dbname"
},
"advancedConfig": "高级配置(JSON)",
"formatJson": "格式化",
@@ -5361,7 +5362,70 @@
},
"connectorTypes": {
"rest": "REST API",
"soap": "SOAP 服务"
"soap": "SOAP 服务",
"database": "数据库直连"
},
"connectorDbKind": {
"mysql": "MySQL",
"oracle": "Oracle",
"sqlserver": "SQL Server",
"postgresql": "PostgreSQL"
},
"endpointLabel": {
"database": "数据库连接串(host:port/service 或 /database)"
},
"bindingSteps": {
"label": "执行步骤(有序)",
"add": "添加步骤",
"remove": "删除步骤",
"moveUp": "上移",
"moveDown": "下移",
"interface": "接口定义",
"paramMapping": "步骤 {index} 参数映射 JSON",
"clientHint": "客户端实例由该步接口归属自动确定:{client}",
"hint": "步骤按数组顺序执行;每步可配置独立的参数映射,客户端实例由各步接口归属自带。"
},
"callLogs": {
"title": "调用记录",
"filterInterface": "接口编码",
"filterClient": "客户端编码",
"filterConnector": "连接类型",
"filterStatus": "状态",
"filterOperationId": "operation_id",
"filterTraceId": "trace_id",
"filterBusinessRef": "业务单号",
"filterKeyword": "参数关键字(模糊搜请求内容)",
"dateFrom": "执行时间起",
"dateTo": "执行时间止",
"query": "查询",
"reset": "重置",
"colTime": "时间",
"colCapability": "能力",
"colInterface": "接口",
"colRef": "单号",
"colStep": "步骤",
"colStatus": "状态",
"colElapsed": "耗时",
"detailTitle": "调用详情",
"timeline": "步骤时间线",
"request": "请求",
"response": "响应",
"wire": "线级请求(wire)",
"rawPayload": "原始报文",
"normalized": "业务参数(归一化)",
"normalizedJson": "归一化 JSON",
"copyBody": "复制 body",
"copyCurl": "复制 curl",
"copySql": "复制 SQL",
"copyRaw": "复制原始报文",
"copyJson": "复制 JSON",
"copyOperationId": "复制 operation_id",
"copyTraceId": "复制 trace_id",
"copied": "已复制",
"noWire": "无线级详情(历史记录)",
"sqlWriteWarning": "⚠ 写入语句:请确认目标环境后再执行",
"prevPage": "上一页",
"nextPage": "下一页"
}
}
}
+72 -8
View File
@@ -5035,7 +5035,8 @@
"interface": "介面定義",
"binding": "繫結",
"credential": "憑證引用",
"capability": "能力清單"
"capability": "能力清單",
"calls": "呼叫日誌"
},
"statusLabels": {
"draft": "草稿",
@@ -5086,7 +5087,7 @@
"environment": "環境",
"status": "狀態",
"clientInstance": "客戶端實例",
"interfaceDef": "介面定義",
"interfaceDef": "介面步驟(有序)",
"secretRef": "Secret 引用",
"secretProvider": "來源",
"account": "帳號",
@@ -5101,6 +5102,7 @@
"code": "編碼",
"name": "名稱",
"connectorType": "連接器類型",
"dbKind": "資料庫類型(db_kind)",
"environment": "環境",
"credentialRef": "憑證引用編碼",
"configJson": "連接配置 JSON(介面位址/逾時/預設 org 等)",
@@ -5122,9 +5124,6 @@
"effectiveTo": "生效結束",
"contextSelector": "進階路由條件 JSON",
"contextSelectorHint": "鍵值對須全部包含於呼叫上下文才會命中;當前版本呼叫方不傳路由上下文,留空即為預設綁定。",
"paramMapping": "參數映射 JSON",
"paramMappingHint": "域參數到介面參數的翻譯規則(如 erp_org→organization、condition 模板);留空=同名直通。",
"bindingClientHint": "隨所選介面定義自動帶出並鎖定,不可單獨修改。",
"secretRef": "Secret 引用鍵",
"secretProvider": "Secret 來源",
"credentialType": "憑證類型",
@@ -5152,7 +5151,8 @@
"msg": {
"fillClient": "請填寫名稱",
"fillInterface": "請選擇客戶端實例(編碼可自動產生)",
"fillBinding": "請填寫能力、客戶端實例與介面定義",
"fillBinding": "請填寫能力,並至少新增一個步驟(每步選擇介面定義)",
"fillDbKind": "請選擇資料庫類型(MySQL / Oracle / SQL Server / PostgreSQL)",
"fillCredential": "請填寫編碼與 Secret 引用",
"fillCredentialDb": "請填寫編碼,以及必填憑據欄位:{fields}",
"credentialTypeMissing": "憑據類型清單未載入,請重新整理頁面後重試",
@@ -5187,7 +5187,8 @@
"endpoint": "https://erp-api.example.com/ws",
"wsdl": "https://erp-api.example.com/wsdl",
"requestPath": "路徑支援佔位符,如 /transfer/xxx",
"passwordKeep": "留空則保持原密碼不變"
"passwordKeep": "留空則保持原密碼不變",
"database": "erp-host:1521/ORCL 或 127.0.0.1:3306/dbname"
},
"advancedConfig": "進階配置(JSON)",
"formatJson": "格式化",
@@ -5208,7 +5209,70 @@
},
"connectorTypes": {
"rest": "REST API",
"soap": "SOAP 服務"
"soap": "SOAP 服務",
"database": "資料庫直連"
},
"connectorDbKind": {
"mysql": "MySQL",
"oracle": "Oracle",
"sqlserver": "SQL Server",
"postgresql": "PostgreSQL"
},
"endpointLabel": {
"database": "資料庫連線字串(host:port/service 或 /database)"
},
"bindingSteps": {
"label": "執行步驟(有序)",
"add": "新增步驟",
"remove": "刪除步驟",
"moveUp": "上移",
"moveDown": "下移",
"interface": "介面定義",
"paramMapping": "步驟 {index} 參數映射 JSON",
"clientHint": "客戶端實例由該步介面歸屬自動確定:{client}",
"hint": "步驟按陣列順序執行;每步可配置獨立的參數映射,客戶端實例由各步介面歸屬自帶。"
},
"callLogs": {
"title": "呼叫記錄",
"filterInterface": "介面編碼",
"filterClient": "客戶端編碼",
"filterConnector": "連線類型",
"filterStatus": "狀態",
"filterOperationId": "operation_id",
"filterTraceId": "trace_id",
"filterBusinessRef": "業務單號",
"filterKeyword": "參數關鍵字(模糊搜尋請求內容)",
"dateFrom": "執行時間起",
"dateTo": "執行時間止",
"query": "查詢",
"reset": "重置",
"colTime": "時間",
"colCapability": "能力",
"colInterface": "介面",
"colRef": "單號",
"colStep": "步驟",
"colStatus": "狀態",
"colElapsed": "耗時",
"detailTitle": "呼叫詳情",
"timeline": "步驟時間線",
"request": "請求",
"response": "回應",
"wire": "線級請求(wire)",
"rawPayload": "原始報文",
"normalized": "業務參數(歸一化)",
"normalizedJson": "歸一化 JSON",
"copyBody": "複製 body",
"copyCurl": "複製 curl",
"copySql": "複製 SQL",
"copyRaw": "複製原始報文",
"copyJson": "複製 JSON",
"copyOperationId": "複製 operation_id",
"copyTraceId": "複製 trace_id",
"copied": "已複製",
"noWire": "無線級詳情(歷史記錄)",
"sqlWriteWarning": "⚠ 寫入語句:請確認目標環境後再執行",
"prevPage": "上一頁",
"nextPage": "下一頁"
}
}
}