Skip to content

Instantly share code, notes, and snippets.

@ikitommi
Last active November 16, 2020 07:17
Show Gist options
  • Save ikitommi/80cc6ddd35c6e9d9b3fec75e0048aa51 to your computer and use it in GitHub Desktop.
Save ikitommi/80cc6ddd35c6e9d9b3fec75e0048aa51 to your computer and use it in GitHub Desktop.
Malli, Clojurists Together Project Update Q3 2020 August 15-31

Clojurists Together Project Update Q3 2020 August 15-31

First goal is to get a stable release of Malli out. This has involved some hammock time, revisiting the design decisions and both designing and implementing features that still could effect the shape of the core apis. And a lot of refactoring. Work is mostly tracked via #116.

Done stuff

Simple Schemas

  • Add utilities for users to easily create simple schemas with property-based validation, including :min and :max ranges for numbers, collections and dates.
  • More built-in schemas: :int, :double, :boolean, :keyword, :symbol, :qualified-keyword, :qualified-symbol and :uuid
  • Closed PRs

EntrySchemas

  • One of the last big things that needs to get done right. Handling of Map Schemas is rewritten lifting MapEntry properties as first class concept for schema applications. This includes new entry value schema type (m/-val-schema), conditional entry walking and a new reusable syntax parser. It's a breaking change for many early adopters and because of that, still in review.
  • PR in review
    • Schema Applications can use MapEntry properties #212
  • Related issues and PRs
    • More Robust Humanized Errors #80
    • Feature request or bug: adding properties directly to map keys #86
    • Define Child/Parent relationship to Schemas #120
    • Rough edges for swagger documentation #182
    • feat: call map-key w/ parent-schema information #119
    • Allow specifying gen/gen and friends on map entries #197

Misc

  • Studied Specter Source for finding more performant ways for doing value transformations. Good stuff.

Clojurists Together Project Update Q3 2020 September 1-15

Small improvements based on user feedback, finalized the EntrySchemas and drafted implementation for heterogenus sequences, aka regex schemas.

Done stuff

  • #212 merged in master, closing 2 other PRs and 3 Issues
  • #251 transformation terms
  • #250 api-docs for public api
  • #116 all known issues for initial alpha are now resolved!

Ongoing

  • #252
    • adding support for lazy registeries (supports pulling e.g. AWS CloudFormation Schemas in at runtime, when needed)
    • lazy :multi impl
    • first class support for String Schema references
    • spell-specking of :multi and :enum values
;; given a lazy registry is provided, pulling the schemas when needed
(def Schema
  [:multi {:dispatch :Type, :lazy true}
   "AWS::ApiGateway::Stage"
   "AWS::ApiGateway::UsagePlan"
   "AWS::AppSync::ApiKey"])

(-> (m/explain
      Schema
      {:Type "AWS::AppSync::ApiKey"
       :Descriptionz "kikka"})
    (me/with-spell-checking)
    (me/humanize))
; ...loaded "AWS::AppSync::ApiKey"
; => {:ApiId ["missing required key"]
;     :Descriptionz ["should be spelled :Description"]}

(-> Schema
    (m/explain
      {:Type "AWS::ApiGatway::UsagePlan"
       :Description "kikka"
       :UsagePlanName "kukka"})
    (me/with-spell-checking)
    (me/humanize))
; => {:Type ["did you mean AWS::ApiGateway::UsagePlan"]}
  • WIP: Heterogenous sequences, aka regex schemas. Studied implementation of clojure.spec, plumatic schema, seqexp and minimallist and drafted an initial clean slate impl. Validation and parsing mostly work, but lot of rough edges and explaining & generation not yet implemented. Kudos to Vincent Cantin for the initial work on this!
;; internal api
(re/parse
  (re/* (re/cat [:prop (re/fn string?)]
                [:val (re/alt [:s (re/fn string?)]
                              [:b (re/fn boolean?)])]))
  ["-server" "foo" "-verbose" true "-user" "joe"])
;[{:prop "-server", :val [:s "foo"]} 
; {:prop "-verbose", :val [:b true]} 
; {:prop "-user", :val [:s "joe"]}]

; malli with named branches
[:* [:cat*
     [:prop string?]
     [:val [:alt*
            [:s string?]
            [:b boolean?]]]]]
            
; malli with indexed branches
[:* [:cat string? [:alt string? boolean?]]]

Misc

All old issues for first alpha are now resolved. Will release it soon, without the regexs (take some time to finish)

Clojurists Together Project Update Q3 2020 September 16-30

Polishing the code, updated dependencies, updated libraries using malli, helped people on slack, though about time, lot's of small improvements, curving out bundle size on js, added type-properties, rewrote a lot of core code to use it, started to write alpha release blog post.

Done stuff

  • kwrooijen/gungnir#31 - update & test Gugnir to use latest malli
  • lambdaisland/regal#20 - update & test Regal to to use latest malli
  • metosin/reitit#fbff819 - update & test Reitit to use latest malli
  • #260 - :map-of keys should decode like String with JSON
  • #116 - just done
  • #254 - easy way to attach custom errors to Schemas
  • #253 - spell checking for :multi map dispatch keys
  • #252 - lazy registries & multis
  • #25 - support core predicates or just keyword types?
  • #244 - won't fix, too special case

Ongoing

  • Writing the alpha release post. Have found out many small inconsistencies and even bugs while writing sample code into the post, need to fix all of those to get the library & post out. Still, really happy how it's all clicking together.

  • Designing how to support schemas for time and dates #49. There is java.time, on JS, Temporal is coming, but while waiting, we have tick and cljc.java-time, but they add a whopping 40-50kb gzipped to bundle size (currently, malli starts ~2kb gzipped). Good discussion about this in clojureverse.

  • carving out js bundle size with great tooling & tips by Thomas Heller via slack. This could be done later, but is so much fun.

Misc

Thought releasing a library was easy, but want to do it right, seems to take time more than expected. Had a flu.

Clojurists Together Project Update Q4 2020 October 01-15

Alpha is out, FINALLY: https://twitter.com/ikitommi/status/1314254607846191104

Done stuff

Ongoing

Misc

4 weeks to go. Will focus on solving real-world issues that people face when adopting the library, update the libs using Malli and try to get some of the larger issues solved.

Clojurists Together Project Update Q5 2020 October 16-31

Fixing things of the alpha, helping people adopting, small stuff.

Done stuff

  • #282 - revisited how references work and how malli.util work with them.
  • #283 - declarative schema transformations
  • #289 - fix :sequential decoding with empty sequence
  • Adopted reitit to use malli, with 3 patch releases 0.5.8, 0.5.9 & 0.5.10

Ongoing

  • helping people adopt malli, small fixes and examples
  • design and prototyping on the Functional Schema Bundle (much bigger than expected):

Misc

no misc now.

Clojurists Together Project Update Q6 2020 November 1-15

Done stuff

  • #295 - fix set explain
  • #298 - fast schema creation
  • #303 - Schemas know th IntoSchema that created it

Ongoing

Misc

  • the three months is over! started bit late, so will continue to work to get the Ongoing (more) done. Already happy with the results, the main goal was to ship the lib. Coudn't have done that without Clojurists Together funding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment