Phase 2 self-review fixes
Critical bugs fixed:
1. Dotted keys produced by ref/object field flattening (e.g. reply.root,
reply.parent) were sent to the PDS as literal flat keys, producing
records that would always fail lexicon validation. Added
unflattenDottedKeys() to convert them back to nested objects before
the XRPC call. Also drops empty optional values so they don't get sent
as empty strings.
2. resolveLocalDef extracted the required-fields array but discarded it,
so the required status of ref-resolved sub-fields was lost. Changed
resolveRefProperties to return { properties, required } (new ResolvedRef
type) and updated flattenRefProperties to AND the schema's required
list with the parent's required status — so optional ref sub-fields
stay optional even when the schema would require them if the ref were
present.
Resource mapper UX improvements:
- Added loadOptionsDependsOn: ['collection'] so getRecordFields is only
called when the NSID changes, not on every editor keystroke.
- Added supportAutoMap: true so users can auto-map input data to fields.
- Added noFieldsError with a helpful message when lexicon resolution fails.
Cleanup:
- Removed unused INodePropertyOptions and ResourceMapperField imports.
- Removed unused 'collection' parameter from buildRecordFromNodeParams.
- Exported buildRecordFromNodeParams + unflattenDottedKeys for testing.
New tests (21 added, 92 total):
- tests/buildRecord.test.ts — 20 tests covering raw JSON, resourceMapper
values, dotted key un-flattening, empty value handling, deep nesting,
and plain object input (from expressions).
- tests/fieldMapping.test.ts — 1 test for the optional-ref-sub-field
required propagation fix.