feat: show the JSON of a document type, an index or a property - #5
Merged
Merged
Conversation
The inspector of a document type, an index or a property ends with its JSON exactly as the contract writes it, collapsed until opened, with light syntax highlighting and a Copy button. An object property shows its members. In compare mode it is the head's JSON, or the base's for what the head removed, and says which. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
QuantumExplorer
added a commit
that referenced
this pull request
Sep 29, 2026
Brings in the inspector's JSON view (#5). The conflicts were both-sides additions: EntityView takes both onShowLayout and version, the README lists both layout.ts and jsonTokens.ts, and styles.css keeps both blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer
added a commit
that referenced
this pull request
Sep 29, 2026
Brings in main's inspector JSON view (#5) through the layout branch. The conflicts were both-sides additions: EntityView takes the layout, cost and version props, the README lists cost.ts and jsonTokens.ts, and styles.css keeps both blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basic explanation
What this does: Clicking a document type, an index or a property in the diagram opens the inspector. The inspector explains what you clicked in plain words, but until now it never showed the JSON the contract actually wrote. It now ends with a JSON of the document type / index / property section: the JSON exactly as written, collapsed until opened, with light syntax highlighting and a Copy button.
Value: you can see the exact source behind any part of the diagram, and copy it, without leaving the page and finding the contract file.
Risks: Low. Display only. The model and the diagram are unchanged.
Before and after
identityIdindex showed its fields and chips (no nulls), but not the JSON behind them.{ "name": "identityId", "nullSearchable": false, "properties": [ { "records.identity": "asc" } ] }recordsincludesproperties.identity.?base=example:dpns&head=example:marketplace, the removedpreordertype shows the base's schema.What was done
src/components/JsonView.tsx(new): a collapsed JSON block with a Copy button. If the clipboard is refused, Copy selects the text instead.src/model/jsonTokens.ts(new): splits pretty-printed JSON into keys, strings, numbers and literals, for highlighting. The tokens join back into the exact text.src/model/introspect.ts:writtenProperty(schema, path)returns a property as written, members included, by its dotted path. A field'swrittenleaves members out, because each member is a field of its own.InspectorPanel.tsx: the section is added to document types, indexes and properties, with the compare-mode label fromdiff.status. The diff'skey2is now exported for that label.written, which leaves out an object's members.$ownerIdhave no JSON section.styles.css: styles for the block. Its colours come from the existing theme variables, so light and dark both work.How Has This Been Tested?
npx vitest run: 82 passing. New tests:tokenizeJson: the tokens join back into the text; it tells keys from string values, including an escaped quote in a key; it finds numbers and literals.writtenProperty: returns a top-level property, an object with its members, and a nested member; returns undefined for a system field or a path the schema lacks.npx tsc -b --noEmitandnpm run build: clean.domain: the JSON parses back to the whole schema, 14 top-level keys.records: the property JSON includesproperties.identityId: the index JSON is as shown above.?base=example:dpns&head=example:marketplace): the removedpreordershows "JSON of the document type · as in base" with the base's schema.This branches from
main. The layout and cost PRs (#3, #4) also add sections to the inspector, so whichever merges second may need a small rebase inInspectorPanel.tsx.🤖 Generated with Claude Code