Merge pull request #3847 from penpot/niwinz-develop-enhancements-11

 Add enhancements and safety checks to copy paste
This commit is contained in:
Aitor Moreno 2023-11-24 14:25:55 +01:00 committed by GitHub
commit 0528c26b5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 1199 additions and 831 deletions

View file

@ -315,6 +315,12 @@
(update :data cpc/process-changes changes)
;; If `libs` is defined, then full validation is performed
(cond-> (contains? cf/flags :soft-file-validation)
(soft-validate-file! libs))
(cond-> (contains? cf/flags :soft-file-schema-validation)
(soft-validate-file-schema!))
(cond-> (and (contains? cf/flags :file-validation)
(not skip-validate))
(val/validate-file! libs))
@ -323,12 +329,6 @@
(not skip-validate))
(val/validate-file-schema!))
(cond-> (contains? cf/flags :soft-file-validation)
(soft-validate-file! libs))
(cond-> (contains? cf/flags :soft-file-schema-validation)
(soft-validate-file-schema!))
(cond-> (and (contains? cfeat/*current* "fdata/objects-map")
(not (contains? cfeat/*previous* "fdata/objects-map")))
(enable-objects-map))

View file

@ -8,7 +8,6 @@
(:require
[app.auth :as auth]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.schema :as sm]
[app.common.uuid :as uuid]
@ -37,7 +36,7 @@
(declare strip-private-attrs)
(declare verify-password)
(def schema:profile
(def ^:private schema:profile
[:map {:title "Profile"}
[:id ::sm/uuid]
[:fullname [::sm/word-string {:max 250}]]
@ -53,14 +52,12 @@
[:props {:optional true}
[:map-of {:title "ProfileProps"} :keyword :any]]])
(def valid-profile?
(sm/pred-fn schema:profile))
;; --- QUERY: Get profile (own)
(sv/defmethod ::get-profile
{::rpc/auth false
::doc/added "1.18"
::sm/params [:map]
::sm/result schema:profile}
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id]}]
;; We need to return the anonymous profile object in two cases, when
@ -93,10 +90,6 @@
::sm/result schema:profile}
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id fullname lang theme] :as params}]
(dm/assert!
"expected valid profile data"
(valid-profile? params))
(db/with-atomic [conn pool]
;; NOTE: we need to retrieve the profile independently if we use
;; it or not for explicit locking and avoid concurrent updates of

View file

@ -28,6 +28,9 @@
(def ^:private schema:templates
[:vector schema:template])
(def check-templates!
(sm/check-fn schema:templates))
(defmethod ig/init-key ::setup/templates
[_ _]
(let [templates (-> "app/onboarding.edn" io/resource slurp edn/read-string)
@ -35,7 +38,7 @@
(dm/verify!
"expected a valid templates file"
(sm/valid? schema:templates templates))
(check-templates! templates))
(doseq [{:keys [id path] :as template} templates]
(let [path (or path (fs/join dest id))]