-
Notifications
You must be signed in to change notification settings - Fork 11
Feat/more schemas injected #2149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
8d5a436 to
88c43fd
Compare
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 101 files
…various new functions
All cell(literal) calls now use widened base types per new spec.
0c3f566 to
9e07835
Compare
When Cell.of<T>() is called with a type argument but no value argument, the schema was incorrectly being placed as the first argument. The schema must always be the second argument, so now undefined is inserted as the first argument when no value is provided. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
… schema
When resolving a link with a remaining path, if `getSchemaAtPath` returns
`undefined` (because the field doesn't exist in the schema), the resolved
link should have no schema property rather than keeping the parent schema.
Previously, the code spread `...nextLink` which would include the original
schema, then conditionally added the new schema only if truthy. This meant
an undefined schema from `getSchemaAtPath` would leave the original schema
in place.
The fix:
1. Destructures `schema` out of `nextLink` to prevent it from being spread
2. Uses `schema \!== undefined` instead of truthiness check to properly
handle empty object schemas `{}`
3. Only adds `schema` back to the result if it's explicitly not undefined
Example: An array schema `{type: "array", items: {type: "number"}}` linked
through a path to `.length` should result in `schema: undefined` since
"length" is not defined in array schemas.
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.
Adds injected schemas for a variety of CT types, eg Cell.of, Cell.for (and the equivalents for other Cell-like types), cell (the constructor), and generateObject
Test plan still only partially implemented but basics seem like they are working
Type narrowing for literal values is hacky and needs improving in a future follow-up
Summary by cubic
Automatically injects JSON schemas into Cell constructors and factory methods, and adds literal type widening to produce simpler, more general schemas. Also fixes link resolution to drop schemas when a remaining path field is not defined.
New Features
Bug Fixes
Written for commit 09ea8b4. Summary will update automatically on new commits.