Repository navigation
proposals: schema explorer tab in the viewer - #11
Conversation
@scottbenton flagged 'schema is a pain point starting out' — proposal doc for adding a Schema tab to the viewer that renders each Datasworn type definition alongside live examples pulled from the currently-loaded content. Reuses the viewer's existing parser, cross-reference resolver, and rendering primitives. Deliberately scoped: - Not a schema editor (read-only) - Not a schema validator (datasworn-build already does that) - Not a replacement for datasworn.schema.json as source of truth Filed as a proposal (not implementation) to solicit feedback on the two open decisions: - Bundle the TS declarations and walk them at runtime, or parse the JSON schema directly? (Lean toward JSON schema.) - Which subset of the 200-ish definitions belong on the left-rail list vs. discoverable via cross-links? (Sketched curated list.) ~3-4 days of viewer work if the shape's agreed. No changes to core.
scottbenton
left a comment
There was a problem hiding this comment.
Thanks for taking this on! I think you've got a really good foundation so far, just left a few comments.
| oracle_rollable (oracle_type: "table_text") | ||
| _id OracleRollableId (required) | ||
| _source SourceInfo (required) | ||
| name Label (required) | ||
| dice DiceExpression (required) | ||
| rows OracleRollableRowText[] (required) | ||
| replaces OracleRollableId[] (optional) | ||
| enhances OracleRollableId[] (optional) |
There was a problem hiding this comment.
This looks good, but we should probably also include the field descriptions from the schema
There was a problem hiding this comment.
Added — the type rendering now shows each field's description straight from the JSON schema, with long ones collapsed to the first sentence behind an expander. Nice side effect: it strengthens the case for parsing the JSON schema (your other comment), since descriptions live right there.
| 1. **Runtime type-graph walk on `@datasworn-community/core`'s TypeScript declarations.** Bundle those into the viewer and reflect over them. Rich (JSDoc, refs, unions) but adds parser complexity to the client. | ||
| 2. **Parse `datasworn.schema.json` (also shipped by core) at load time.** Simpler; the JSON schema already has the fields, unions, `$ref`s, descriptions. Missing the ergonomics of the TS declarations but sufficient for a Schema tab. | ||
|
|
||
| Leaning toward **(2)** — the JSON schema is a well-defined data structure, whereas walking TS types at runtime is inference-heavy. Open to arguments for (1). |
There was a problem hiding this comment.
Agreed. I think this is cleaner
There was a problem hiding this comment.
Resolved to (2) — parse datasworn.schema.json at load time. With field descriptions also coming from the schema, one artifact carries everything the panel needs.
|
|
||
| ## Open questions | ||
|
|
||
| 1. **How much of the type universe is worth surfacing?** Datasworn's schema has ~200 definitions; not all are interesting to a new contributor. Curated list of "primary" types (matching the left rail sketch above) + everything else discoverable via cross-links seems right. |
There was a problem hiding this comment.
This makes sense. Keeping the main
rules
moves
oracles
assets
truths
(and related categories) will make things much easier!
There was a problem hiding this comment.
Regrouped the left rail exactly along those lines — Rules / Moves / Oracles / Assets / Truths plus the Delve family — with the rest of the ~200-definition universe reachable via cross-links rather than listed. e50a97e
| ## Open questions | ||
|
|
||
| 1. **How much of the type universe is worth surfacing?** Datasworn's schema has ~200 definitions; not all are interesting to a new contributor. Curated list of "primary" types (matching the left rail sketch above) + everything else discoverable via cross-links seems right. | ||
| 2. **Should the Schema tab load schemas at different versions?** Related to the [single-schema-line viewer policy](https://github.com/datasworn-community/viewer/pull/4) — if the viewer pins to one line, the Schema tab pins to the same line. Multi-version schema browsing is out of scope until multi-version content browsing is. |
There was a problem hiding this comment.
I'd start with only the most recent version? If we have a breaking schema change, perhaps then we'd want to revisit. Thoughts?
There was a problem hiding this comment.
Agreed — most recent version only. It also matches the single-schema-line viewer policy (viewer#4), so the Schema tab and the loaded content always describe the same line. Noted that we revisit if a breaking schema change ships while older-line content stays relevant.
|
|
||
| 1. **How much of the type universe is worth surfacing?** Datasworn's schema has ~200 definitions; not all are interesting to a new contributor. Curated list of "primary" types (matching the left rail sketch above) + everything else discoverable via cross-links seems right. | ||
| 2. **Should the Schema tab load schemas at different versions?** Related to the [single-schema-line viewer policy](https://github.com/datasworn-community/viewer/pull/4) — if the viewer pins to one line, the Schema tab pins to the same line. Multi-version schema browsing is out of scope until multi-version content browsing is. | ||
| 3. **Should this eventually live in `@datasworn-community/core` docs** (auto-published somewhere) rather than exclusively in the viewer? Probably yes long-term — but a viewer Schema tab is a good MVP because it can piggy-back on the viewer's existing loading pipeline. |
There was a problem hiding this comment.
Hmm I think it living in the viewer makes sense for now. As we make changes, the core schema version will not always match the content schema versions, so that mismatch might cause issues.
There was a problem hiding this comment.
Agreed, and captured your reasoning in the doc: a docs site published from core would drift from the content packages' schema versions, whereas viewer-side the tab and the content it exemplifies stay on the same line by construction. Removed the "eventually move to core docs" framing.
- Type rendering now includes per-field descriptions straight from the JSON schema's description strings (collapsed to first sentence with an expander for long ones). - Type-info source resolved: parse datasworn.schema.json (option 2). - Left rail regrouped into the categories consumers think in: rules, moves, oracles, assets, truths, delve — instead of a flat type list. - Version scope resolved: most recent schema version only, revisit on a breaking change. - Location resolved: stays in the viewer — core schema version won't always match content schema versions, so viewer-side keeps the tab and the loaded content on the same line.
|
All five comments addressed in e50a97e — field descriptions added to the type rendering, JSON-schema parsing locked in as the type source, left rail regrouped into rules/moves/oracles/assets/truths (+ delve), and both remaining open questions resolved your way (latest version only; lives in the viewer). The proposal has no open questions left — happy to start on the implementation once the viewer PR stack clears. |
Motivating quote
@scottbenton on the initial-port review:
Filing as a proposal to sort out the shape before implementing.
Proposal in one paragraph
Add a Schema tab to the viewer. For each Datasworn type (`move`, `oracle_rollable`, `asset`, etc.), render the field-by-field type definition alongside 2–3 live examples pulled from currently-loaded content. Cross-links between types so `OracleRollableRow.text: MarkdownString` clicks through to `MarkdownString`. The viewer already has the parser, the ID resolver, and the rendering primitives — reusing them for types rather than only for content is cheap.
Full doc
`proposals/viewer-schema-explorer.md`
What I'm looking for
Feedback on two open questions:
Non-goals also called out (not an editor, not a validator, JSON schema stays canonical, don't just dump the schema string).
Estimated ~3–4 days of viewer work if the shape's agreed.