67da186672
- Add context config endpoints (GET/PUT /api/ai/prompts/:type/:version/context-config) - Add execution profile endpoints (CRUD /api/ai/execution-profiles) - Add sandbox RAG Prep endpoint (POST /api/ai/admin/sandbox/rag-prep) - Create Prompt Management UI with multi-type support - Add ContextConfigEditor, PromptEditor, RuntimeParametersPanel components - Add SandboxTabs for 3-step workflow (OCR, Extract, RAG Prep) - Add database deltas for ai_execution_profiles and additional prompt types - Update quickstart.md with production backend URLs - Add comprehensive test coverage for new features
3.5 KiB
3.5 KiB
Session — 2026-06-14 (RFA ADR-001/021 Migration — Complete)
Summary
ทำ RFA Workflow Migration ให้เสร็จครบ — ตัด templateId ออกจาก DTO ทั้ง frontend/backend,
ลบ deprecated routing-template entities + RfaWorkflowService ออกจาก rfa.module.ts,
เพิ่ม static constants ที่หายไปใน RfaService, และอัปเดต tests ให้ align กับ contract ใหม่
ผลลัพธ์: tsc --noEmit exit 0 + 26/26 frontend tests pass
ปัญหาที่พบ (Root Cause)
rfa.service.tsอ้างอิงRfaService.WORKFLOW_CODE,RfaService.STATE_TO_STATUS,RfaService.DEFAULT_APPROVED_CODEแต่ไม่มีการ declare static constants เหล่านี้ในคลาส → TS2339 compile errorSubmitRfaDto(backend + frontend) ยังมีtemplateIdซึ่งถูกตัดออกจาก service signature แล้วrfa.module.tsยังนำเข้า deprecated entities:RfaWorkflow,RfaWorkflowTemplate,RfaWorkflowTemplateStep,CorrespondenceRouting,RoutingTemplate,RoutingTemplateStepและRfaWorkflowServicedetail.tsxยังมีtemplateIdstate + "Routing Template ID" input +Labelที่ไม่จำเป็น- Test files ยังอ้างอิง
templateId: 1ใน submit DTO และ'Routing Template ID'assertion
การแก้ไข (Fix)
| ไฟล์ | การเปลี่ยนแปลง |
|---|---|
backend/src/modules/rfa/dto/submit-rfa.dto.ts |
ตัด templateId field + @IsInt + @IsNotEmpty ออก; เหลือแค่ reviewTeamPublicId? |
backend/src/modules/rfa/rfa.module.ts |
ลบ RfaWorkflow, RfaWorkflowTemplate, RfaWorkflowTemplateStep, CorrespondenceRouting, RoutingTemplate, RoutingTemplateStep ออกจาก imports/forFeature; ลบ RfaWorkflowService จาก providers |
backend/src/modules/rfa/rfa.service.ts |
เพิ่ม static readonly constants: WORKFLOW_CODE = 'RFA_APPROVAL', STATE_TO_STATUS (Record), DEFAULT_APPROVED_CODE = '1A' |
frontend/lib/services/rfa.service.ts |
ตัด templateId: number ออกจาก SubmitRfaDto interface |
frontend/components/rfas/detail.tsx |
ตัด templateId state + setter + "Routing Template ID" <input> block ออก; handleSubmit() ส่งแค่ { reviewTeamPublicId } |
frontend/lib/services/__tests__/rfa.service.test.ts |
อัปเดต submit test DTO: { reviewTeamPublicId: 'uuid-team' } (ไม่มี templateId) |
frontend/components/rfas/__tests__/detail.test.tsx |
ลบ expect(screen.getByText('Routing Template ID')).toBeInTheDocument() |
กฎที่ Lock แล้ว
- RFA submit contract:
POST /rfas/:uuid/submitรับเฉพาะ{ reviewTeamPublicId?: string }— ไม่มีtemplateId - Workflow Code:
RFA_APPROVAL(static constant ในคลาส ห้าม hardcode ในแต่ละ method) - STATE_TO_STATUS map:
DRAFT→DFT,CONSULTANT_REVIEW→FRE,OWNER_REVIEW→FAP,APPROVED→FCO - DEFAULT_APPROVED_CODE:
'1A'(fallback เมื่อ payload ไม่มี approveCode)
Verification
npx tsc --noEmit(backend) → exit 0, no type errorsnpx vitest run lib/services/__tests__/rfa.service.test.ts components/rfas/__tests__/detail.test.tsx→ 26/26 passed