From 71ba0242c708cedb0e62a1afe84eb81649bbdd16 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 2 Sep 2024 16:34:03 +0200 Subject: [PATCH] :bug: Add missing type decoding on changes schema --- common/src/app/common/files/changes.cljc | 17 +++++++++++------ common/src/app/common/types/page.cljc | 18 +++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index a46c02352..40a253759 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -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)) diff --git a/common/src/app/common/types/page.cljc b/common/src/app/common/types/page.cljc index 1c3bef33b..b49755115 100644 --- a/common/src/app/common/types/page.cljc +++ b/common/src/app/common/types/page.cljc @@ -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))