-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow computed objects and arrays without using object
or array
#42
Comments
jkomoros
added a commit
that referenced
this issue
Jul 8, 2023
…trary nested Array or Object. Required manually defining a few types to get around a zod recursion issue, but they're simple types. Part of #42.
jkomoros
added a commit
that referenced
this issue
Jul 8, 2023
For some reason the schema doesn't update? Part of #42.
jkomoros
added a commit
that referenced
this issue
Jul 8, 2023
jkomoros
added a commit
that referenced
this issue
Jul 8, 2023
Also, make tests for nested use a typescriptt type instead of a seedPacket.parse. This catches errors at authoring time, ahead of testing time. (Before it wasn't possible due to typing limitations, but I guess I fixed that at some point?) Part of #42.
jkomoros
added a commit
that referenced
this issue
Jul 8, 2023
…y inject necessary `array` and `object` seeds during seed packet expansion. The upshot is that you can now skip including manual `object` or `array` seed types in seed defintions and they will be added for you. One gotcha is that sub-objects cannot contain the properties `seed` or `type`, otherwise they will be interpreted as a sub_seed. (This was technically always true though). This is a gnarly commit with a terrifyingly complex expandSeedComputedObjects method. The only reason I have any confidence whatsoever that it works is that tests pass. Part of #42.
This is done as of cb74ab6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to have an object or array with computed sub-properties, you have to wrap it in either a
type:object
ortype:array
. This is annoying, easy to get wrong, and adds an unnessecary level of extra indirection during authoring.As a pre-processing step before the seed packet has nested seeds unrolled, process the object. Iterate through them, and if we find any with a SeedReference or SeedData property, then replace the parent with a
type:object
wrapper (and do the same for arrays, too). This should be a pretty simple transformation and handle most cases fine.(Once we make it so seed references have a
seed
, notid
property, it will make this behavior even more resilient... as long as your sub-objects don't have atype
orseed
property then it will work as you think.)The text was updated successfully, but these errors were encountered: