0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:private
schema:operation
(def schema:operation
[:multi {:dispatch :type
:title "Operation"
:decode/json #(update % :type keyword)
@ -61,9 +60,12 @@
[:type [:= :set-remote-synced]]
[:remote-synced {:optional true} [:maybe :boolean]]]]])
(sm/register! ::change
(def schema:change
[:schema
[:multi {:dispatch :type :title "Change" ::smd/simplified true}
[:multi {:dispatch :type
:title "Change"
:decode/json #(update % :type keyword)
::smd/simplified true}
[:set-option
[:map {:title "SetOptionChange"}
[:type [:= :set-option]]
@ -256,8 +258,11 @@
[:type [:= :del-typography]]
[:id ::sm/uuid]]]]])
(sm/register! ::changes
[:sequential {:gen/max 2} ::change])
(def schema:changes
[:sequential {:gen/max 5 :gen/min 1} schema:change])
(sm/register! ::change schema:change)
(sm/register! ::changes schema:changes)
(def check-change!
(sm/check-fn ::change))

View file

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