From 65a2b1087561ca1cbbd22d9fe17b0000f7957253 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 7 Oct 2025 18:10:49 +0200 Subject: [PATCH] :sparkles: Make component path mandatory on validations And ensure it already present with a migration --- common/src/app/common/files/changes.cljc | 4 +--- common/src/app/common/files/migrations.cljc | 10 +++++++++- common/src/app/common/types/component.cljc | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 89ce23ddcb..0d12396f3c 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -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]]]] diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index f368db6069..1531642dc9 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -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"])) diff --git a/common/src/app/common/types/component.cljc b/common/src/app/common/types/component.cljc index 1b773f1c51..70266435a3 100644 --- a/common/src/app/common/types/component.cljc +++ b/common/src/app/common/types/component.cljc @@ -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]