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]]
[:id ::sm/uuid]
[:name :string]
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
[:path {:optional true} :string]
[:path :string]
[:main-instance-id ::sm/uuid]
[:main-instance-page ::sm/uuid]
;; Only used by external processes (like Penpot SDK)
@@ -331,7 +330,6 @@
[:id ::sm/uuid]
[:name {:optional true} :string]
[:path {:optional true} :string]
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
[:variant-id {:optional true} ::sm/uuid]
[:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]]

View File

@@ -1605,6 +1605,13 @@
(update :pages-index 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
(into (d/ordered-set)
["legacy-2"
@@ -1673,4 +1680,5 @@
"0009-add-partial-text-touched-flags"
"0010-fix-swap-slots-pointing-non-existent-shapes"
"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
[:id ::sm/uuid]
[:name :string]
[:path {:optional true} [:maybe :string]]
[:path :string]
[:modified-at {:optional true} ::ct/inst]
[:objects {:gen/max 10 :optional true} ctp/schema:objects]
[:main-instance-id ::sm/uuid]