Make component path mandatory on validations

And ensure it already present with a migration
This commit is contained in:
Andrey Antukh 2025-10-07 18:10:49 +02:00
parent 9e676a7ab2
commit 65a2b10875
3 changed files with 11 additions and 5 deletions

View File

@ -317,8 +317,7 @@
[:type [:= :add-component]] [:type [:= :add-component]]
[:id ::sm/uuid] [:id ::sm/uuid]
[:name :string] [:name :string]
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:path :string]
[:path {:optional true} :string]
[:main-instance-id ::sm/uuid] [:main-instance-id ::sm/uuid]
[:main-instance-page ::sm/uuid] [:main-instance-page ::sm/uuid]
;; Only used by external processes (like Penpot SDK) ;; Only used by external processes (like Penpot SDK)
@ -331,7 +330,6 @@
[:id ::sm/uuid] [:id ::sm/uuid]
[:name {:optional true} :string] [:name {:optional true} :string]
[:path {:optional true} :string] [:path {:optional true} :string]
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
[:variant-id {:optional true} ::sm/uuid] [:variant-id {:optional true} ::sm/uuid]
[:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]] [:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]]

View File

@ -1605,6 +1605,13 @@
(update :pages-index d/update-vals update-container) (update :pages-index d/update-vals update-container)
(d/update-when :components d/update-vals update-container)))) (d/update-when :components d/update-vals update-container))))
(defmethod migrate-data "0013-fix-component-path"
[data _]
(let [update-component
(fn [component]
(update component :path #(d/nilv % "")))]
(d/update-when data :components d/update-vals update-component)))
(def available-migrations (def available-migrations
(into (d/ordered-set) (into (d/ordered-set)
["legacy-2" ["legacy-2"
@ -1673,4 +1680,5 @@
"0009-add-partial-text-touched-flags" "0009-add-partial-text-touched-flags"
"0010-fix-swap-slots-pointing-non-existent-shapes" "0010-fix-swap-slots-pointing-non-existent-shapes"
"0011-fix-invalid-text-touched-flags" "0011-fix-invalid-text-touched-flags"
"0012-fix-position-data"])) "0012-fix-position-data"
"0013-fix-component-path"]))

View File

@ -23,7 +23,7 @@
[:map [:map
[:id ::sm/uuid] [:id ::sm/uuid]
[:name :string] [:name :string]
[:path {:optional true} [:maybe :string]] [:path :string]
[:modified-at {:optional true} ::ct/inst] [:modified-at {:optional true} ::ct/inst]
[:objects {:gen/max 10 :optional true} ctp/schema:objects] [:objects {:gen/max 10 :optional true} ctp/schema:objects]
[:main-instance-id ::sm/uuid] [:main-instance-id ::sm/uuid]