0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

🐛 Add missing type decoding on changes schema

This commit is contained in:
Andrey Antukh 2024-09-02 16:34:03 +02:00
parent 9fb91b3052
commit 71ba0242c7
2 changed files with 22 additions and 13 deletions

View file

@ -31,8 +31,7 @@
;; SCHEMAS ;; SCHEMAS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:private (def schema:operation
schema:operation
[:multi {:dispatch :type [:multi {:dispatch :type
:title "Operation" :title "Operation"
:decode/json #(update % :type keyword) :decode/json #(update % :type keyword)
@ -61,9 +60,12 @@
[:type [:= :set-remote-synced]] [:type [:= :set-remote-synced]]
[:remote-synced {:optional true} [:maybe :boolean]]]]]) [:remote-synced {:optional true} [:maybe :boolean]]]]])
(sm/register! ::change (def schema:change
[:schema [:schema
[:multi {:dispatch :type :title "Change" ::smd/simplified true} [:multi {:dispatch :type
:title "Change"
:decode/json #(update % :type keyword)
::smd/simplified true}
[:set-option [:set-option
[:map {:title "SetOptionChange"} [:map {:title "SetOptionChange"}
[:type [:= :set-option]] [:type [:= :set-option]]
@ -256,8 +258,11 @@
[:type [:= :del-typography]] [:type [:= :del-typography]]
[:id ::sm/uuid]]]]]) [:id ::sm/uuid]]]]])
(sm/register! ::changes (def schema:changes
[:sequential {:gen/max 2} ::change]) [:sequential {:gen/max 5 :gen/min 1} schema:change])
(sm/register! ::change schema:change)
(sm/register! ::changes schema:changes)
(def check-change! (def check-change!
(sm/check-fn ::change)) (sm/check-fn ::change))

View file

@ -18,20 +18,20 @@
;; SCHEMAS ;; SCHEMAS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(sm/register! ::flow (def schema:flow
[:map {:title "PageFlow"} [:map {:title "Flow"}
[:id ::sm/uuid] [:id ::sm/uuid]
[:name :string] [:name :string]
[:starting-frame ::sm/uuid]]) [:starting-frame ::sm/uuid]])
(sm/register! ::guide (def schema:guide
[:map {:title "PageGuide"} [:map {:title "Guide"}
[:id ::sm/uuid] [:id ::sm/uuid]
[:axis [::sm/one-of #{:x :y}]] [:axis [::sm/one-of #{:x :y}]]
[:position ::sm/safe-number] [:position ::sm/safe-number]
[:frame-id {:optional true} [:maybe ::sm/uuid]]]) [:frame-id {:optional true} [:maybe ::sm/uuid]]])
(sm/register! ::page (def schema:page
[:map {:title "FilePage"} [:map {:title "FilePage"}
[:id ::sm/uuid] [:id ::sm/uuid]
[:name :string] [:name :string]
@ -42,11 +42,15 @@
[:background {:optional true} ::ctc/rgb-color] [:background {:optional true} ::ctc/rgb-color]
[:saved-grids {:optional true} ::ctg/saved-grids] [:saved-grids {:optional true} ::ctg/saved-grids]
[:flows {:optional true} [:flows {:optional true}
[:vector {:gen/max 2} ::flow]] [:vector {:gen/max 2} schema:flow]]
[:guides {:optional true} [:guides {:optional true}
[:map-of {:gen/max 2} ::sm/uuid ::guide]] [:map-of {:gen/max 2} ::sm/uuid schema:guide]]
[:plugin-data {:optional true} ::ctpg/plugin-data]]]]) [:plugin-data {:optional true} ::ctpg/plugin-data]]]])
(sm/register! ::page schema:page)
(sm/register! ::guide schema:guide)
(sm/register! ::flow schema:flow)
(def check-page-guide! (def check-page-guide!
(sm/check-fn ::guide)) (sm/check-fn ::guide))