mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 05:51:38 +02:00
🐛 Fix path content json decoding mechanism
This commit is contained in:
parent
1981946480
commit
122e5a4b57
1 changed files with 24 additions and 17 deletions
|
@ -586,9 +586,6 @@
|
||||||
(def ^:private check-segments
|
(def ^:private check-segments
|
||||||
(sm/check-fn schema:segments))
|
(sm/check-fn schema:segments))
|
||||||
|
|
||||||
(sm/register! ::path/segment schema:segment)
|
|
||||||
(sm/register! ::path/segments schema:segments)
|
|
||||||
|
|
||||||
(defn path-data?
|
(defn path-data?
|
||||||
[o]
|
[o]
|
||||||
(instance? PathData o))
|
(instance? PathData o))
|
||||||
|
@ -596,24 +593,34 @@
|
||||||
(declare from-string)
|
(declare from-string)
|
||||||
(declare from-plain)
|
(declare from-plain)
|
||||||
|
|
||||||
|
;; Mainly used on backend: features/components_v2.clj
|
||||||
|
(sm/register! ::path/segment schema:segment)
|
||||||
|
(sm/register! ::path/segments schema:segments)
|
||||||
|
|
||||||
(sm/register!
|
(sm/register!
|
||||||
{:type ::path/content
|
{:type ::path/content
|
||||||
:pred path-data?
|
:compile
|
||||||
:type-properties
|
(fn [_ _ _]
|
||||||
{:gen/gen (->> (sg/generator schema:segments)
|
(let [decoder (delay (sm/decoder schema:segments sm/json-transformer))
|
||||||
(sg/filter not-empty)
|
generator (->> (sg/generator schema:segments)
|
||||||
(sg/fmap #(from-plain %)))
|
(sg/filter not-empty)
|
||||||
:encode/json identity
|
(sg/fmap from-plain))]
|
||||||
:decode/json (fn [s]
|
{:pred path-data?
|
||||||
(cond
|
:type-properties
|
||||||
(string? s)
|
{:gen/gen generator
|
||||||
(from-string s)
|
:encode/json identity
|
||||||
|
:decode/json (fn [s]
|
||||||
|
(cond
|
||||||
|
(string? s)
|
||||||
|
(from-string s)
|
||||||
|
|
||||||
(vector? s)
|
(vector? s)
|
||||||
(from-plain s)
|
(let [decode-fn (deref decoder)]
|
||||||
|
(-> (decode-fn s)
|
||||||
|
(from-plain)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
s))}})
|
s))}}))})
|
||||||
|
|
||||||
(def check-path-content
|
(def check-path-content
|
||||||
(sm/check-fn ::path/content))
|
(sm/check-fn ::path/content))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue