- Build process now transpiles all files. All dist files now work as Common.JS rather than a mix of Common.JS and ES6 modules.
- Fix build process when
index.js.flow
is not present on disk.
- We now use the
prepare
script to build the application. This makes maintenance life a little easier, and consumption is now easier for folks who want to iterate on a branch offlow-degen
. - Fix a syntax error in one of the examples (no executable change).
- Upgrade various build time dependencies - no runtime vulnerabilities were addressed (and none known).
- Add Github Actions!
- A bug was introduced in the recent addition of Flow utility type support.
When
degenEnum
was used with a $PropertyType a syntax error would occurr due to unescaped quote characters. This bug is now fixed. - Appease security gods by bumping dependency versions, even though there is zero security threat here.
degenList
,degenMapping
, anddegenRefiner
all now requireMetaType
information in the leading parameters. In the case ofdegenMapping
there are two (key and value). The “Fixes” section outlines the motivations.- The
typeParams
field inMetaType
has been made optional. This could impact custom generators that use this field.
- We are now explicitly using types at the call sites for
degenList
,degenMapping
, anddegenRefiner
. This should reduce the level of type inferencing the generated refiners place upon Flow, and in many cases will reduce errors outright because Flow just didn’t have enough to go off of. See the “Breaking” section for details as to how this breaks the interfaces for these functions, and how you can address it.
degenObject
now takes a list of optional fields as a new argument at the end of the argument list. The simplest thing to do is add[]
as the last parameter to your calls, and you will have the same behavior as before.codeGen
takes aprettify
flag as the second argument. Usetrue
for this argument to keep your original behavior.
- The
degenObject
generator now takes a list of optional fields so any field that is an optional type (not necessarily a maybe type) can also be supported by the system. - Consumers of
codeGen
may now indicate whether or not to prettify the code when running. This can be helpful when running tests and you want the generated output to display and a syntax error causesprettier
to fail. This way you can still limp by and see the generated code. typeHeader
is now exported. Documentation to follow soon!degenMapping
is properly exported.
- Reduce the amount of type inferencing
flow-degen
relies upon. Consumers can easily run into a “recursion limit exceeded” issue with Flow. To work around this, some functions have been made to specifically indicate their type parameters at the call sites. This has been shown to fix the problem, but it is difficult to build tests towards.
Nothing here - Logan messed up the publish and hadn’t staged any changes. Derp.
degenMaybe
added to create refiners for maybe types (type Foo = ?string).
- Fix an issue where
flow-degen
could no longer be recognized as an imported module by Flow. This is related to recent changes to makeflow-degen
work whenstrict
is enabled. It is not well understood what rolestrict
played to cause a problem with the library, but it is suspected to be a difference in Flow versions. The old./index.js.flow
workaround has been restored, yet we still retain the originalstrict
fix.
- Actually expose
degenRefiner
for consumption.
- It’s possible your
baseDir
usage is now broken due to building uponflow-degen
’s broken behavior regarding it.
degenRefiner
added to link to other refiners by symbol name. This effectively turns into animport
statement and a function call in the generated refiner code. The symbol name can allow for recursive calls, and will significantly reduce the size of refiners instead of inlining the entire refiner. Thanks @gyrfalcon!- A usage example has been added for
degenList
.
- How
baseDir
in the configuration is used is now fixed. - Consumption of
flow-degen
should actually work when you usestrict
options in your repository.
- The
generators
configuration key is now a new structure and will break old consumers’ configuration files. Instead of a flat input/output file mapping, each pairing is represented with a structure that indicates (still) an input and output file, but also input and output exports. Consumers will now need to identify the exports to be used (rather than assumingdefault
) and indicate how those identifiers map to a generated version. - Consumers can no longer import the
default
of generated files. Instead consumers must indicate specific exported identifiers. - There is a verbiage change in the works to stop using the word
“deserializer” due to its inaccuracy. Instead “refiner” is preferred. The
input these generated functions take is already deserialized. “Validator”
is a poor term. While
flow-degen
might be able to ensure thestructure
of data is valid, there are many ways to go about being valid such as accounting for state machine transitions or making sure a user token hasn’t expired. Perhaps one could make the generated functions do these things, this has not been the focus of this library. Ultimatelyflow-degen
is about taking in some unknown input and emitting an expected structure or an error detailing why the input doesn’t satisfy the requirements.
- An example of how to use
degenString
has been added. - An example of how to put together a custom generator has been added.
- Configuration files can now indicate multiple refiners per file (both input and output). This paves the way for recursion - a feature in the near future. It also allows the refiner code to become significantly smaller when arranged for re-use.
- The new
generatedPreamble
field is required and will break configurations that lack it.
- Added
generatedPreamble
to the configuration, which gets added to the top of generated files.
- Use
@flow strict
for generated files.0.8.0
did not actually accomplish this. - Fix some type coverage in
deserializer.js
which is a runtime file.
- Use an exhaustive-union check to ensure your disjoint-union/sum types are checking for every member of the union.
- When
JSON.stringify
receives amixed
it can beundefined
as its output instead ofstring
. Thestringify
utility has been added which will return the string =’undefined’= in the case ofundefined
. Use =@flow strict= for generated files.Adding@flow strict
did not happen in this release but instead in0.9.0
.- Fix a bug where the
deString
dependency fromdegenEnum
wasn’t being chained out ofdegenSum
. The test framework is still being put together so this wasn’t fully tested.
- Add documentation for
degenSentinelValue
,degenSum
, anddegenValue
. - Introduced a changelog.
- Internally, there is now an automated test for generation and checking for Flow errors.
- Internally, source files now use the
@flow strict
annotation.