V25 · Firebase emulator thật hơn

Chuẩn hóa write path cho API submit R4 vào Firestore emulator.

API không ghi thẳng Firestore; dữ liệu đi qua auth, guard, repository, consent, adapter và audit.

Contract

POST /api/r4/submit-firestore-dev

participant-private write path qua consent gate

api

1. Nhận POST /api/r4/submit-firestore-dev với payload tối thiểu.

Không được: Không nhận raw profile mở rộng hoặc dữ liệu ngoài schema.

auth

2. Xác minh Firebase ID token hoặc token emulator.

Không được: Không tin role từ body request.

guard

3. Kiểm tra role/action submit_r4.

Không được: Không cho organization_observer submit thay người tham gia.

repository

4. Chuẩn hóa payload thành R4Response.

Không được: Không ghi thẳng Firestore từ API route.

consent

5. Kiểm tra consent scope store_r4_response.

Không được: Không lưu nếu consent revoked hoặc thiếu scope.

adapter

6. Ghi qua FirestoreAdapter/FirestoreAdminAdapter.

Không được: Không overwrite submission trùng ID.

audit

7. Append auditEvents/{auditId}.

Không được: Không update/delete audit event cũ.