Raw Data Editing (Mọi field)
Cam kết LumiBase: bất kỳ field nào (trừ
encryptedthiếu quyền) cũng có thể chỉnh ở chế độ Raw.
1. UX
- Mỗi field có icon "{ }" ở góc input để toggle Raw mode.
- Modal hoặc inline collapse, Monaco editor với:
- Language theo type (
json,html,markdown,plain). - Schema validation (JSON Schema derived từ
type+validation). - Side-by-side preview cho
wysiwyg,markdown,image.
- Language theo type (
- Action:
Apply,Cancel,Reset to last saved,Format.
2. Bulk raw editor
- Trang detail item có nút "Raw item JSON" mở toàn bộ document ở Monaco.
- Cho phép paste JSON, validate qua schema collection, hiển thị danh sách lỗi.
3. Contract
ts
interface RawTransport<TValue> {
toRaw(value: TValue): string;
fromRaw(raw: string): TValue;
language: 'json' | 'html' | 'markdown' | 'plain' | 'sql' | 'yaml';
schema?: JSONSchema7; // dùng cho monaco validate
}
- Mặc định cho mọi interface:
JSON.stringify/parsevới 2 spaces. - Interface có thể override (vd.
wysiwyg.toRaw = htmlthuần).
4. Server-side
- Endpoint cập nhật item nhận payload bình thường (đã
fromRawở client). Server không phân biệt raw hay không. - Tuy nhiên có endpoint
POST /items/:c/:id/rawđể gửi nguyên block JSON toàn document (sẽ validate toàn bộ schema collection, áp permissionupdate+ field mask).
5. Bảo mật
encryptedfield: Raw mode chỉ hiển thị khi user có permissionread:decrypted. Ngược lại field hiển thị*** (encrypted)read-only.- Audit: ghi
raw_editvào activity với diff (trước/sau).
6. Edge cases
- Field type
csv: raw là chuỗi CSV, có button "convert to array preview". - Field relation: raw là array of foreign keys; preview hiển thị display template của target collection.
- Field
geometry: raw là GeoJSON; preview render map.