Releases: mlms13/bs-decode
v1.2.0
This release fixes a couple very minor bugs and adds a handful of new helper functions to ease the transition away from deprecated features, in preparation for the eventual 2.0 release.
I fully expect this to be the final release in the 1.x cycle (but I'll continue making releases if additional issues are found).
✨ New features
arrayAt
allows decoding specific positions within an array. This will eventually replace the provided tuple decoders (which are now deprecated)null
is a decoder that expects exactly the JSONnull
value. Internally, this allows us to simplify optional decodersarrayJson
,listJson
, anddictJson
each allow decoding the outer structure while preserving the inner JSON. This is another change that will eventually help simplify some of the code for the more complex decoders
🐛 Bug fixes
v1.1.0
This release adds helpers to ease the transition away from the deprecated features in the 1.0 release. Barring any bugs that require fixing, this is the last planned release in the 1.x series.
⚠️ Deprecated features
- Some deprecations mentioned in the previous release notes weren't actually deprecated in the code. Those will now trigger compiler warnings.
✨ New features
hush
is a new function that takes aDecode.AsResult.OfParseError
decoder and converts it into aJs.Json.t => option('a)
decoder (effectively "hushing" the error). This should make the transition away fromDecode.AsOption
easier.literalBool
,literalTrue
, andliteralFalse
join the otherliteral*
decoders that first decode, then further validate the outputintUnion
works likestringUnion
and should make the transition away fromvariantFromInt
easier
v1.0
Version 1.0 is here! Very little has changed since 0.11.2; mostly this release indicates the stability (or lack of maintenance, depending on how you look at it) over the last several years. The 1.x releases will be the last to support BuckleScript as we turn our attention to Melange.
There are no breaking changes in this release, but there are a handful of deprecations. We should end up with decent alternatives to all of the features that will eventually be removed, but if any of this concerns you, please let me know!
⚠️ Deprecated features
Decode.AsResult.OfStringNel
will be removed in an upcoming release. The errors are less useful thanOfParseError
, and there's a cost to maintaining multiple decoder typesDecode.AsOption
will also be removed. Again, there's a maintenance burden in keeping it, and if you really wantoption
, it's easy enough to convert theresult
return into anoption
.Decode.Make
(for making your own custom output types) will eventually be removed as we focus onParseError
variantFromJson
andvariantFromString
will be removed in favor of new, simpler, more consistent tools for decoding variants (see the newliteral
functions below)- The
Decode.Pipeline
module is now deprecated. See the docs for alternatives and a teaser about upcoming changes that will make this experience way better stringMap
will be removed as we try to limit how much we depend on Belt-specific features. You can use thedict
decoder instead and convert theJs.Dict
to aBelt.String.Map
.
✨ New features
- Functions have been added to decode literal values e.g.
literalString
,literalInt
, andliteralFloat
. These functions first decode to the expected type, then ensure the value exactly matches the provided value. This is useful for decoding unions of string literals (e.g."dev" | "prod"
) - Decoding sting unions is such a common need that we've provided a
stringUnion
function to make it even simpler
📝 Documentation
- The documentation site got a handful of updates to explain the deprecations
- The guide on decoding variants was almost completely rewritten and might be particularly helpful
🤖 Dependency updates
bs-bastet
was bumped to2.0
andrelude
was bumped to0.66.1
. As peer dependencies, this change is the most likely to impact your existing projects, but hopefully the update isn't too bad
v0.11.2
🐛 Bug fixes
- Compiled output files will no longer have a
/./
in the middle of the path, which causes issues with some bundlers/dev setups (thanks @hamza0867 for finding and fixing this!)
v0.11.1
🐛 Bug fixes
- Revert the
public
flag in thebsconfig.json
. There are apparently some strange quirks that cause aliased modules not to compile in downstream projects, so I got rid of it. You still shouldn't need to accessDecode_*
modules directly (instead useDecode.AsWhatever
) but those modules won't be hidden from you.
v0.11.0
🚨 Breaking changes
- The
bs-abstract
peer-dependency is nowbs-bastet
, and the required Relude version is 0.59+. See the Relude release notes and the Bastet migration guide for details. - Alias everything in
Decode
and prevent direct access to theDecode_*
modules via Bucklescript'spublic
flag
✨ New features
okJson
is a decoder that always passes and preserves the input JSON
v0.10.0
🚨 Breaking changes
- All error-related types now live in
Decode.ParseError
. Specifically, this means thatDecodeBase.failure
is nowDecode.ParseError.base
, which is important if you're extending the base errors to create your own custom errors. - Using
ParseError.ResultOf
will return a module that conforms toMONAD
instead of giving you aMonad
submodule back. This is consistent with our shift toward structural typeclasses instead of named typeclasses. This is only a breaking change if you extend the underlying error type, and the tests have been updated if you're looking for an example.
📝 Documentation
- README explains peer dependencies better
- Nested array decoding is demonstrated in the tests
- Haskell-style object decoding operates on the decoders, not the result
✔️ Code quality
- Bump dependencies and allow compilation with BuckleScript 7.1
- Internally, use structural typing for typeclasses rather than named modules
v0.9.0
v0.8.1
v0.8.0
🚨 Breaking
- Long-deprecated
int
andfloat
functions have been removed. You should be usingintFromNumber
andfloatFromNumber
instead to avoid shadowing issues tuple
(which previously contructed atuple
from a JSON object) is nowtupleFromFields
- Base
failure
type now includes anExpectedTuple(int)
constructor, whereint
is the expected size. This is only a breaking change if you're manually matching on values of the basefailure
type.
✨ New features
- JSON arrays can now be decoded directly into tuples using
tuple2
...tuple5
(which will fail if the JSON array is larger than expected) ortupleAtLeast2
...tupleAtLeast5
(which will tolerate longer arrays)