实现 Booking Excel 预处理接入 SuperAgent

This commit is contained in:
andy
2026-07-20 00:32:01 +07:00
parent b7b04cf1ac
commit d1955f5097
45 changed files with 2955 additions and 10 deletions

View File

@@ -766,6 +766,7 @@ export default {
parsedJson: 'Parsed JSON',
rawAnswer: 'Raw answer',
warnings: 'Warnings',
bookingExcelExtractions: 'Booking Excel attachment extraction',
debugPayload: 'Debug payload',
statuses: {
idle: 'Idle',

View File

@@ -766,6 +766,7 @@ export default {
parsedJson: 'JSON ที่แยกแล้ว',
rawAnswer: 'คำตอบดิบ',
warnings: 'คำเตือน',
bookingExcelExtractions: 'การแยกไฟล์แนบ Booking Excel',
debugPayload: 'Debug payload',
statuses: {
idle: 'รออัปโหลด',

View File

@@ -766,6 +766,7 @@ export default {
parsedJson: '解析 JSON',
rawAnswer: '原始回答',
warnings: '警告',
bookingExcelExtractions: 'Booking Excel 附件预处理',
debugPayload: '调试 Payload',
statuses: {
idle: '待上传',

View File

@@ -273,6 +273,9 @@ function normalizeDebugEmlResult(payload: unknown): DebugEmlSuperAgentRunResult
typeof result.html_sanitize_required === 'boolean' ? result.html_sanitize_required : null,
html_render_mode: nullableStringValue(result.html_render_mode),
agentbus_like_payload: isRecord(result.agentbus_like_payload) ? result.agentbus_like_payload : null,
attachment_extractions: Array.isArray(result.attachment_extractions)
? result.attachment_extractions.filter(isRecord)
: [],
superagent_session_id: nullableStringValue(result.superagent_session_id),
superagent_run_id: nullableStringValue(result.superagent_run_id),
superagent_raw_answer: nullableStringValue(result.superagent_raw_answer),

View File

@@ -84,6 +84,14 @@ describe('debugEmlService', () => {
html_sanitize_required: true,
html_render_mode: 'SANITIZED_HTML',
agentbus_like_payload: { schema_version: 'debug-eml-upload-v1' },
attachment_extractions: [
{
file_type: 'BOOKING_UPDATE',
month_filter: {
selected_months: ['2026-05'],
},
},
],
superagent_session_id: 'session-1',
superagent_run_id: 'run-1',
superagent_raw_answer: '{"ok":true}',
@@ -102,6 +110,14 @@ describe('debugEmlService', () => {
})
expect(fetchMock).toHaveBeenCalledTimes(1)
expect(result.attachment_extractions).toEqual([
{
file_type: 'BOOKING_UPDATE',
month_filter: {
selected_months: ['2026-05'],
},
},
])
const [url, init] = fetchMock.mock.calls[0]!
expect(url).toBe('/api/system/debug/eml-superagent-runs')
expect(init).toMatchObject({

View File

@@ -63,6 +63,14 @@ function createResult() {
original_message_id: '<original@example.test>',
},
},
attachment_extractions: [
{
file_type: 'BOOKING_UPDATE',
month_filter: {
selected_months: ['2026-05'],
},
},
],
superagent_session_id: 'session-1',
superagent_run_id: 'run-1',
superagent_raw_answer: '{"ok":true}',
@@ -176,6 +184,9 @@ describe('DebugEmlSuperAgentRunView', () => {
expect(wrapper.find('.debug-eml-html-preview').html()).not.toContain('<script>')
expect(wrapper.find('.debug-eml-html-preview').html()).not.toContain('onclick')
expect(wrapper.text()).toContain('booking.eml')
expect(wrapper.text()).toContain('Booking Excel 附件预处理')
expect(wrapper.text()).toContain('"file_type": "BOOKING_UPDATE"')
expect(wrapper.text()).toContain('"selected_months"')
expect(wrapper.text()).toContain('"schema_version": "debug-eml-upload-v1"')
expect(wrapper.text()).toContain('"ok": true')
})

View File

@@ -31,6 +31,7 @@ export interface DebugEmlSuperAgentRunResult {
html_sanitize_required: boolean | null
html_render_mode: 'SANITIZED_HTML' | 'TEXT_ONLY' | string | null
agentbus_like_payload: Record<string, unknown> | null
attachment_extractions: Record<string, unknown>[]
superagent_session_id: string | null
superagent_run_id: string | null
superagent_raw_answer: string | null

View File

@@ -357,6 +357,22 @@
</details>
</section>
<section
v-if="result.attachment_extractions.length"
class="debug-eml-card"
>
<div class="th-section-header">
<h2 class="th-section-title">
<i
class="pi pi-file-excel"
aria-hidden="true"
/>
{{ t('debugEml.bookingExcelExtractions') }}
</h2>
</div>
<pre>{{ formatJson(result.attachment_extractions) }}</pre>
</section>
<section class="debug-eml-card debug-eml-result-section">
<div class="th-section-header">
<h2 class="th-section-title">