0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

Apply schema improvements to profile rpc methods

This commit is contained in:
Andrey Antukh 2023-11-27 16:10:30 +01:00
parent 9b36ea99e6
commit a91b2f1133

View file

@ -37,21 +37,23 @@
(declare strip-private-attrs) (declare strip-private-attrs)
(declare verify-password) (declare verify-password)
(def ^:private schema:profile (def ^:private
[:map {:title "Profile"} schema:profile
[:id ::sm/uuid] (sm/define
[:fullname [::sm/word-string {:max 250}]] [:map {:title "Profile"}
[:email ::sm/email] [:id ::sm/uuid]
[:is-active {:optional true} :boolean] [:fullname [::sm/word-string {:max 250}]]
[:is-blocked {:optional true} :boolean] [:email ::sm/email]
[:is-demo {:optional true} :boolean] [:is-active {:optional true} :boolean]
[:is-muted {:optional true} :boolean] [:is-blocked {:optional true} :boolean]
[:created-at {:optional true} ::sm/inst] [:is-demo {:optional true} :boolean]
[:modified-at {:optional true} ::sm/inst] [:is-muted {:optional true} :boolean]
[:default-project-id {:optional true} ::sm/uuid] [:created-at {:optional true} ::sm/inst]
[:default-team-id {:optional true} ::sm/uuid] [:modified-at {:optional true} ::sm/inst]
[:props {:optional true} [:default-project-id {:optional true} ::sm/uuid]
[:map-of {:title "ProfileProps"} :keyword :any]]]) [:default-team-id {:optional true} ::sm/uuid]
[:props {:optional true}
[:map-of {:title "ProfileProps"} :keyword :any]]]))
;; --- QUERY: Get profile (own) ;; --- QUERY: Get profile (own)
@ -79,11 +81,13 @@
;; --- MUTATION: Update Profile (own) ;; --- MUTATION: Update Profile (own)
(def schema:update-profile (def ^:private
[:map {:title "update-profile"} schema:update-profile
[:fullname [::sm/word-string {:max 250}]] (sm/define
[:lang {:optional true} [:string {:max 5}]] [:map {:title "update-profile"}
[:theme {:optional true} [:string {:max 250}]]]) [:fullname [::sm/word-string {:max 250}]]
[:lang {:optional true} [:string {:max 5}]]
[:theme {:optional true} [:string {:max 250}]]]))
(sv/defmethod ::update-profile (sv/defmethod ::update-profile
{::doc/added "1.0" {::doc/added "1.0"
@ -124,11 +128,13 @@
(declare update-profile-password!) (declare update-profile-password!)
(declare invalidate-profile-session!) (declare invalidate-profile-session!)
(def schema:update-profile-password (def ^:private
[:map {:title "update-profile-password"} schema:update-profile-password
[:password [::sm/word-string {:max 500}]] (sm/define
;; Social registered users don't have old-password [:map {:title "update-profile-password"}
[:old-password {:optional true} [:maybe [::sm/word-string {:max 500}]]]]) [:password [::sm/word-string {:max 500}]]
;; Social registered users don't have old-password
[:old-password {:optional true} [:maybe [::sm/word-string {:max 500}]]]]))
(sv/defmethod ::update-profile-password (sv/defmethod ::update-profile-password
{:doc/added "1.0" {:doc/added "1.0"
@ -178,9 +184,11 @@
(declare upload-photo) (declare upload-photo)
(declare update-profile-photo) (declare update-profile-photo)
(def schema:update-profile-photo (def ^:private
[:map {:title "update-profile-photo"} schema:update-profile-photo
[:file ::media/upload]]) (sm/define
[:map {:title "update-profile-photo"}
[:file ::media/upload]]))
(sv/defmethod ::update-profile-photo (sv/defmethod ::update-profile-photo
{:doc/added "1.1" {:doc/added "1.1"
@ -242,9 +250,11 @@
(declare ^:private request-email-change!) (declare ^:private request-email-change!)
(declare ^:private change-email-immediately!) (declare ^:private change-email-immediately!)
(def schema:request-email-change (def ^:private
[:map {:title "request-email-change"} schema:request-email-change
[:email ::sm/email]]) (sm/define
[:map {:title "request-email-change"}
[:email ::sm/email]]))
(sv/defmethod ::request-email-change (sv/defmethod ::request-email-change
{::doc/added "1.0" {::doc/added "1.0"
@ -309,9 +319,11 @@
;; --- MUTATION: Update Profile Props ;; --- MUTATION: Update Profile Props
(def schema:update-profile-props (def ^:private
[:map {:title "update-profile-props"} schema:update-profile-props
[:props [:map-of :keyword :any]]]) (sm/define
[:map {:title "update-profile-props"}
[:props [:map-of :keyword :any]]]))
(sv/defmethod ::update-profile-props (sv/defmethod ::update-profile-props
{::doc/added "1.0" {::doc/added "1.0"