Skip to content

proposals: schema explorer tab in the viewer - #11

Merged
tbsvttr merged 2 commits into
mainfrom
proposals/viewer-schema-explorer
Jul 22, 2026
Merged

tbsvttr merged 2 commits into
mainfrom
proposals/viewer-schema-explorer

Conversation

@tbsvttr

@tbsvttr tbsvttr commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Motivating quote

@scottbenton on the initial-port review:

Wrapping my head around the schema was always a pain point for me starting out. If there was a way people could interact with the schema in the viewer (and maybe see examples of a given oracle type or other thing) I think that would be a really useful addition!

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:

  1. Where the type info comes from — parse `datasworn.schema.json` at runtime (simple, well-defined) vs. bundle and walk the TypeScript declarations (rich, but inference-heavy). Lean toward the JSON schema.
  2. Which subset of the ~200 schema definitions belongs on the left-rail list vs. only discoverable via cross-links. Curated draft is in the doc.

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.

@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.
@tbsvttr tbsvttr self-assigned this Jul 16, 2026
@tbsvttr
tbsvttr requested a review from scottbenton July 16, 2026 10:32

@scottbenton scottbenton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on! I think you've got a really good foundation so far, just left a few comments.

Comment on lines +75 to +82
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but we should probably also include the field descriptions from the schema

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread proposals/viewer-schema-explorer.md Outdated
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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think this is cleaner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread proposals/viewer-schema-explorer.md Outdated

## 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. Keeping the main

rules
moves
oracles
assets
truths

(and related categories) will make things much easier!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread proposals/viewer-schema-explorer.md Outdated
## 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd start with only the most recent version? If we have a breaking schema change, perhaps then we'd want to revisit. Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread proposals/viewer-schema-explorer.md Outdated

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@tbsvttr

tbsvttr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

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.

@tbsvttr
tbsvttr merged commit ce87130 into main Jul 22, 2026
@tbsvttr
tbsvttr deleted the proposals/viewer-schema-explorer branch July 22, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants