7 Commits

Author SHA1 Message Date
febea43708
refactor: move shouldMergeObjects from rawpaths to heuristics 2026-06-11 19:12:17 -06:00
fbd00ae4d2
feat: merge object shapes with optional fields in raw paths 2026-06-11 19:10:26 -06:00
2b7f3f137b
feat(jsontypes): add -samples flag and {undefined} sentinel to raw paths
Add RawPathsConfig with SampleLen to show truncated sample values
instead of type names at leaf nodes (e.g., {"Alice Anglerso..."} instead
of {string}). Add absentValue sentinel to distinguish fields absent
from a struct instance ({undefined}) vs explicitly null ({null}).
2026-06-11 16:14:38 -06:00
ffed4a5e17
fix(jsontypes): use {empty} instead of {any} for empty collections
{any} implies we inspected values and found mixed types. {empty} is
honest: we saw an empty array or object and have no type information.
2026-06-11 16:14:38 -06:00
a346049cc4
feat(jsontypes): short raw paths — type name only on intro line
Type names now appear once on the intro line, and subsequent fields
use the bare path without repeating the type. Root no longer has a
leading dot.

Before: .{Root0}.rooms[]{RoomsItem1}._timing{Timing2}.account_ms{int}
After:  .rooms[]._timing.account_ms{int}

The type intro line declares the type, making the path structure
cleaner and more readable while remaining lossless.
2026-06-11 16:14:38 -06:00
439558a8ac
feat(jsontypes): simplify map detection to 3 rules, add API test fixtures
Rewrote looksLikeMap from 6 layered heuristics down to 3 simple rules:
1. All numeric keys → map (certain)
2. Any key composed of words → struct (certain)
3. Everything else → map (safe default)

The asymmetry is deliberate: a map misidentified as a struct explodes
into hundreds of fields, while a struct misidentified as a map is
compact and easy to fix.

Word detection splits keys on _ and camelCase, checks segments for
pronounceability (vowel/consonant rhythm). Short words (id, at, on)
only count when paired with a strong 3+ char word.

Also adds raw path type naming with Item suffix for collections
(FriendsItem instead of Friend), real API test fixtures from PokeAPI
and SWAPI, and UUID-based test data replacing synthetic abc123 keys.
2026-06-11 16:14:38 -06:00
b58c09350b
feat(jsontypes): add RawPaths and jsonrawpaths CLI
RawPaths walks JSON depth-first and emits flat paths with monotonically
numbered type names (Root0, People2, etc.). Each type intro immediately
precedes its fields, making the output streamable and order-stable.

Also improves map detection heuristics:
- All-numeric keys are always maps (even with 1-2 keys)
- Keys containing digits detected as IDs (e.g., emp_101)
- New isKnownFieldName with broad list of common field names
  (timestamps, flags, relations, etc.) as strong struct signal
2026-06-11 16:14:38 -06:00