Raw Data Editing (every field)
LumiBase commitment: every field can be edited in Raw mode — the sole exception being an
encryptedfield the user lacks permission for.
1. UX
- Every field has a "{ }" icon in the corner of its input to toggle Raw mode.
- Either a modal or an inline collapse, with a Monaco editor providing:
- Language chosen by type (
json,html,markdown,plain). - Schema validation (a JSON Schema derived from
type+validation). - Side-by-side preview for
wysiwyg,markdown,image.
- Language chosen by type (
- Actions:
Apply,Cancel,Reset to last saved,Format.
2. Bulk raw editor
- The item detail page has a "Raw item JSON" button that opens the whole document in Monaco.
- You can paste JSON, have it validated against the collection schema, and see the list of errors.
3. Contract
ts
interface RawTransport<TValue> {
toRaw(value: TValue): string;
fromRaw(raw: string): TValue;
language: 'json' | 'html' | 'markdown' | 'plain' | 'sql' | 'yaml';
schema?: JSONSchema7; // used for monaco validation
}
- Default for every interface:
JSON.stringify/parsewith 2 spaces. - An interface may override it (e.g.
wysiwyg.toRawreturns plain HTML).
4. Server-side
- The item update endpoint receives an ordinary payload —
fromRawhas already run on the client. The server does not distinguish raw from non-raw. - There is, however, a
POST /items/:c/:id/rawendpoint for submitting the whole document as one JSON block; it validates against the full collection schema and applies theupdatepermission plus the field mask.
5. Security
encryptedfields: Raw mode is only offered when the user holds theread:decryptedpermission. Otherwise the field renders read-only as*** (encrypted).- Audit: a
raw_editentry is written to activity with the before/after diff.
6. Edge cases
- Field type
csv: the raw form is a CSV string, with a "convert to array preview" button. - Relation fields: the raw form is an array of foreign keys; the preview renders the target collection's display template.
geometryfields: the raw form is GeoJSON; the preview renders a map.