From 4e753dc4743fa549358bdb4f5727115e40ab7762 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 8 Jul 2025 08:51:19 +0200 Subject: [PATCH] :lipstick: Use resolved schemas instead of references For several schemas on common types --- common/src/app/common/files/validate.cljc | 1 - common/src/app/common/types/container.cljc | 29 +++++++++++----------- common/src/app/common/types/file.cljc | 14 +++++------ common/src/app/common/types/page.cljc | 4 +-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 0fe15a067c..75650ca97d 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -669,7 +669,6 @@ :file-id (:id file) :details errors))) - (declare compare-slots) ;; Optional check to look for missing swap slots. diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 89e210d871..6c7e468314 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -15,7 +15,7 @@ [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] [app.common.types.pages-list :as ctpl] - [app.common.types.plugins :as ctpg] + [app.common.types.plugins :refer [schema:plugin-data]] [app.common.types.shape-tree :as ctst] [app.common.types.shape.layout :as ctl] [app.common.types.text :as cttx] @@ -30,21 +30,22 @@ (def valid-container-types #{:page :component}) -(sm/register! - ^{::sm/type ::container} - [:map - [:id ::sm/uuid] - [:type {:optional true} - [::sm/one-of valid-container-types]] - [:name :string] - [:path {:optional true} [:maybe :string]] - [:modified-at {:optional true} ::sm/inst] - [:objects {:optional true} - [:map-of {:gen/max 10} ::sm/uuid :map]] - [:plugin-data {:optional true} ::ctpg/plugin-data]]) +(def schema:container + (sm/register! + ^{::sm/type ::container} + [:map + [:id ::sm/uuid] + [:type {:optional true} + [::sm/one-of valid-container-types]] + [:name :string] + [:path {:optional true} [:maybe :string]] + [:modified-at {:optional true} ::sm/inst] + [:objects {:optional true} + [:map-of {:gen/max 10} ::sm/uuid :map]] + [:plugin-data {:optional true} schema:plugin-data]])) (def check-container - (sm/check-fn ::container)) + (sm/check-fn schema:container)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HELPERS diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index 521915da96..651b1b58c4 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -23,9 +23,9 @@ [app.common.types.container :as ctn] [app.common.types.page :as ctp] [app.common.types.pages-list :as ctpl] - [app.common.types.plugins :as ctpg] + [app.common.types.plugins :refer [schema:plugin-data]] [app.common.types.shape-tree :as ctst] - [app.common.types.tokens-lib :as ctl] + [app.common.types.tokens-lib :refer [schema:tokens-lib]] [app.common.types.typographies-list :as ctyl] [app.common.types.typography :as cty] [app.common.uuid :as uuid] @@ -61,13 +61,13 @@ [:map-of {:gen/max 5} ::sm/uuid ctc/schema:library-color]) (def schema:components - [:map-of {:gen/max 5} ::sm/uuid ::ctn/container]) + [:map-of {:gen/max 5} ::sm/uuid ctn/schema:container]) (def schema:typographies - [:map-of {:gen/max 2} ::sm/uuid ::cty/typography]) + [:map-of {:gen/max 2} ::sm/uuid cty/schema:typography]) (def schema:pages-index - [:map-of {:gen/max 5} ::sm/uuid ::ctp/page]) + [:map-of {:gen/max 5} ::sm/uuid ctp/schema:page]) (def schema:options [:map {:title "FileOptions"} @@ -82,8 +82,8 @@ [:colors {:optional true} schema:colors] [:components {:optional true} schema:components] [:typographies {:optional true} schema:typographies] - [:plugin-data {:optional true} ::ctpg/plugin-data] - [:tokens-lib {:optional true} ::ctl/tokens-lib]]) + [:plugin-data {:optional true} schema:plugin-data] + [:tokens-lib {:optional true} schema:tokens-lib]]) (def schema:file "A schema for validate a file data structure; data is optional diff --git a/common/src/app/common/types/page.cljc b/common/src/app/common/types/page.cljc index 230f7460d7..ee6084bd66 100644 --- a/common/src/app/common/types/page.cljc +++ b/common/src/app/common/types/page.cljc @@ -53,10 +53,10 @@ [:name :string] [:index {:optional true} ::sm/int] [:objects schema:objects] - [:default-grids {:optional true} ::ctg/default-grids] + [:default-grids {:optional true} ctg/schema:default-grids] [:flows {:optional true} schema:flows] [:guides {:optional true} schema:guides] - [:plugin-data {:optional true} ::ctpg/plugin-data] + [:plugin-data {:optional true} ctpg/schema:plugin-data] [:background {:optional true} ctc/schema:hex-color] [:comment-thread-positions {:optional true}