Skip to content
Snippets Groups Projects
Unverified Commit 18d190cf authored by Ngoc Khuat's avatar Ngoc Khuat Committed by GitHub
Browse files

Move Plumatic schema in `metabase.util.schema` to `metabase.util.malli.schema` (#27622)

* move malli schema from metabase.util.schema to a new ns metabase.util.malli.schema

* revert name changes for plumatic schema. e.g: NonBlankStringPlumatic -> NonBlankString

* add clj-kondo rule to enforce consistent alias for metabase.util.malli.schema
parent 26423c63
No related branches found
No related tags found
No related merge requests found
Showing
with 56 additions and 55 deletions
...@@ -353,6 +353,7 @@ ...@@ -353,6 +353,7 @@
metabase.util.i18n i18n metabase.util.i18n i18n
metabase.util.i18n.impl i18n.impl metabase.util.i18n.impl i18n.impl
metabase.util.malli mu metabase.util.malli mu
metabase.util.malli.schema ms
metabase.util.password u.password metabase.util.password u.password
metabase.util.schema su metabase.util.schema su
metabase.util.ui-logic ui-logic metabase.util.ui-logic ui-logic
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
- Permissions have three levels: full, limited, and none. - Permissions have three levels: full, limited, and none.
- Native query download permissions are fully inferred from the non-native download permissions. For more details, - Native query download permissions are fully inferred from the non-native download permissions. For more details,
see the docstring for [[metabase.models.permissions/update-native-download-permissions!]]." see the docstring for [[metabase.models.permissions/update-native-download-permissions!]]."
[group-id :- su/IntGreaterThanZeroPlumatic db-id :- su/IntGreaterThanZeroPlumatic new-download-perms :- perms/DownloadPermissionsGraph] [group-id :- su/IntGreaterThanZero db-id :- su/IntGreaterThanZero new-download-perms :- perms/DownloadPermissionsGraph]
(when-not (premium-features/enable-advanced-permissions?) (when-not (premium-features/enable-advanced-permissions?)
(throw (perms/ee-permissions-exception :download))) (throw (perms/ee-permissions-exception :download)))
(when-let [schemas (:schemas new-download-perms)] (when-let [schemas (:schemas new-download-perms)]
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
(s/defn update-db-data-model-permissions! (s/defn update-db-data-model-permissions!
"Update the data model permissions graph for a database." "Update the data model permissions graph for a database."
[group-id :- su/IntGreaterThanZeroPlumatic db-id :- su/IntGreaterThanZeroPlumatic new-data-model-perms :- perms/DataModelPermissionsGraph] [group-id :- su/IntGreaterThanZero db-id :- su/IntGreaterThanZero new-data-model-perms :- perms/DataModelPermissionsGraph]
(when-not (premium-features/enable-advanced-permissions?) (when-not (premium-features/enable-advanced-permissions?)
(throw (perms/ee-permissions-exception :data-model))) (throw (perms/ee-permissions-exception :data-model)))
(when-let [schemas (:schemas new-data-model-perms)] (when-let [schemas (:schemas new-data-model-perms)]
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
(s/defn update-db-details-permissions! (s/defn update-db-details-permissions!
"Update the DB details permissions for a database." "Update the DB details permissions for a database."
[group-id :- su/IntGreaterThanZeroPlumatic db-id :- su/IntGreaterThanZeroPlumatic new-perms :- perms/DetailsPermissions] [group-id :- su/IntGreaterThanZero db-id :- su/IntGreaterThanZero new-perms :- perms/DetailsPermissions]
(when-not (premium-features/enable-advanced-permissions?) (when-not (premium-features/enable-advanced-permissions?)
(throw (perms/ee-permissions-exception :details))) (throw (perms/ee-permissions-exception :details)))
(case new-perms (case new-perms
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
(s/defn update-db-execute-permissions! (s/defn update-db-execute-permissions!
"Update the DB details permissions for a database." "Update the DB details permissions for a database."
[group-id :- su/IntGreaterThanZeroPlumatic db-id :- su/IntGreaterThanZeroPlumatic new-perms :- perms/ExecutePermissions] [group-id :- su/IntGreaterThanZero db-id :- su/IntGreaterThanZero new-perms :- perms/ExecutePermissions]
(when-not (premium-features/enable-advanced-permissions?) (when-not (premium-features/enable-advanced-permissions?)
(throw (perms/ee-permissions-exception :execute))) (throw (perms/ee-permissions-exception :execute)))
(revoke-permissions! :execute :all group-id db-id) (revoke-permissions! :execute :all group-id db-id)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
(def ^:private ApplicationPermissionsGraph (def ^:private ApplicationPermissionsGraph
{:revision s/Int {:revision s/Int
:groups {su/IntGreaterThanZeroPlumatic GroupPermissionsGraph}}) :groups {su/IntGreaterThanZero GroupPermissionsGraph}})
;; -------------------------------------------------- Fetch Graph --------------------------------------------------- ;; -------------------------------------------------- Fetch Graph ---------------------------------------------------
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
(def ResultsMetadata (def ResultsMetadata
"Schema for the expected format for `:metadata` returned by an internal query function." "Schema for the expected format for `:metadata` returned by an internal query function."
(su/non-empty (su/non-empty
[[(s/one su/KeywordOrStringPlumatic "field name") [[(s/one su/KeywordOrString "field name")
(s/one {:base_type su/FieldTypePlumatic, :display_name su/NonBlankStringPlumatic, s/Keyword s/Any} (s/one {:base_type su/FieldType, :display_name su/NonBlankString, s/Keyword s/Any}
"field metadata")]])) "field metadata")]]))
(defmulti internal-query (defmulti internal-query
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
;; ORDER BY {{group-fn(timestamp}} ASC ;; ORDER BY {{group-fn(timestamp}} ASC
(s/defn views-by-time (s/defn views-by-time
"Get views of a Card or Dashboard broken out by a time `unit`, e.g. `day` or `day-of-week`." "Get views of a Card or Dashboard broken out by a time `unit`, e.g. `day` or `day-of-week`."
[model :- ModelName, model-id :- su/IntGreaterThanZeroPlumatic, unit :- common/DateTimeUnitStr] [model :- ModelName, model-id :- su/IntGreaterThanZero, unit :- common/DateTimeUnitStr]
{:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type unit)}] {:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type unit)}]
[:views {:display_name "Views", :base_type :type/Integer}]] [:views {:display_name "Views", :base_type :type/Integer}]]
:results (let [grouped-timestamp (common/grouped-datetime unit :timestamp)] :results (let [grouped-timestamp (common/grouped-datetime unit :timestamp)]
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
(s/defn cached-views-by-time (s/defn cached-views-by-time
"Get number of views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week` and by cache status. "Get number of views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week` and by cache status.
Still here instead of in cards because of similarity to views-by-time" Still here instead of in cards because of similarity to views-by-time"
[card-id :- su/IntGreaterThanZeroPlumatic, unit :- common/DateTimeUnitStr] [card-id :- su/IntGreaterThanZero, unit :- common/DateTimeUnitStr]
{:metadata [[:date {:display_name "Date", {:metadata [[:date {:display_name "Date",
:base_type (common/datetime-unit-str->base-type unit)}] :base_type (common/datetime-unit-str->base-type unit)}]
[:cached-views {:display_name "Cached Views", [:cached-views {:display_name "Cached Views",
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
(s/defn avg-execution-time-by-time (s/defn avg-execution-time-by-time
"Get average execution time of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`. "Get average execution time of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`.
Still here instead of in cards because of similarity to views-by-time" Still here instead of in cards because of similarity to views-by-time"
[card-id :- su/IntGreaterThanZeroPlumatic, unit :- common/DateTimeUnitStr] [card-id :- su/IntGreaterThanZero, unit :- common/DateTimeUnitStr]
{:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type unit)}] {:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type unit)}]
[:avg_runtime {:display_name "Average Runtime", :base_type :type/Number}]] [:avg_runtime {:display_name "Average Runtime", :base_type :type/Number}]]
:results (let [grouped-timestamp (common/grouped-datetime unit :started_at)] :results (let [grouped-timestamp (common/grouped-datetime unit :started_at)]
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
(s/defn revision-history (s/defn revision-history
"Get a revision history table for a Card or Dashboard." "Get a revision history table for a Card or Dashboard."
[model-entity :- (s/cond-pre (mi/InstanceOf Card) (mi/InstanceOf Dashboard)) [model-entity :- (s/cond-pre (mi/InstanceOf Card) (mi/InstanceOf Dashboard))
model-id :- su/IntGreaterThanZeroPlumatic] model-id :- su/IntGreaterThanZero]
{:metadata [[:timestamp {:display_name "Edited on", :base_type :type/DateTime}] {:metadata [[:timestamp {:display_name "Edited on", :base_type :type/DateTime}]
[:user_id {:display_name "User ID", :base_type :type/Integer, :remapped_to :user_name}] [:user_id {:display_name "User ID", :base_type :type/Integer, :remapped_to :user_name}]
[:user_name {:display_name "Edited by", :base_type :type/Name, :remapped_from :user_id}] [:user_name {:display_name "Edited by", :base_type :type/Name, :remapped_from :user_id}]
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
(s/defn audit-log (s/defn audit-log
"Get a view log for a Card or Dashboard." "Get a view log for a Card or Dashboard."
[model :- ModelName, model-id :- su/IntGreaterThanZeroPlumatic] [model :- ModelName, model-id :- su/IntGreaterThanZero]
{:metadata [[:when {:display_name "When", :base_type :type/DateTime}] {:metadata [[:when {:display_name "When", :base_type :type/DateTime}]
[:user_id {:display_name "User ID", :base_type :type/Integer, :remapped_to :who}] [:user_id {:display_name "User ID", :base_type :type/Integer, :remapped_to :who}]
[:who {:display_name "Who", :base_type :type/Name, :remapped_from :user_id}] [:who {:display_name "Who", :base_type :type/Name, :remapped_from :user_id}]
......
...@@ -11,22 +11,22 @@ ...@@ -11,22 +11,22 @@
;; Get views of a Dashboard broken out by a time `unit`, e.g. `day` or `day-of-week`. ;; Get views of a Dashboard broken out by a time `unit`, e.g. `day` or `day-of-week`.
(s/defmethod audit.i/internal-query ::views-by-time (s/defmethod audit.i/internal-query ::views-by-time
[_ dashboard-id :- su/IntGreaterThanZeroPlumatic datetime-unit :- common/DateTimeUnitStr] [_ dashboard-id :- su/IntGreaterThanZero datetime-unit :- common/DateTimeUnitStr]
(card-and-dash-detail/views-by-time "dashboard" dashboard-id datetime-unit)) (card-and-dash-detail/views-by-time "dashboard" dashboard-id datetime-unit))
;; Revision history for a specific Dashboard. ;; Revision history for a specific Dashboard.
(s/defmethod audit.i/internal-query ::revision-history (s/defmethod audit.i/internal-query ::revision-history
[_ dashboard-id :- su/IntGreaterThanZeroPlumatic] [_ dashboard-id :- su/IntGreaterThanZero]
(card-and-dash-detail/revision-history Dashboard dashboard-id)) (card-and-dash-detail/revision-history Dashboard dashboard-id))
;; View log for a specific Dashboard. ;; View log for a specific Dashboard.
(s/defmethod audit.i/internal-query ::audit-log (s/defmethod audit.i/internal-query ::audit-log
[_ dashboard-id :- su/IntGreaterThanZeroPlumatic] [_ dashboard-id :- su/IntGreaterThanZero]
(card-and-dash-detail/audit-log "dashboard" dashboard-id)) (card-and-dash-detail/audit-log "dashboard" dashboard-id))
;; Information about the Saved Questions (Cards) in this instance. ;; Information about the Saved Questions (Cards) in this instance.
(s/defmethod audit.i/internal-query ::cards (s/defmethod audit.i/internal-query ::cards
[_ dashboard-id :- su/IntGreaterThanZeroPlumatic] [_ dashboard-id :- su/IntGreaterThanZero]
{:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}] {:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}]
[:card_name {:display_name "Title", :base_type :type/Name, :remapped_from :card_id}] [:card_name {:display_name "Title", :base_type :type/Name, :remapped_from :card_id}]
[:collection_id {:display_name "Collection ID", :base_type :type/Integer, :remapped_to :collection_name}] [:collection_id {:display_name "Collection ID", :base_type :type/Integer, :remapped_to :collection_name}]
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
;; Query execution history for queries against this Database. ;; Query execution history for queries against this Database.
(s/defmethod audit.i/internal-query ::audit-log (s/defmethod audit.i/internal-query ::audit-log
[_ database-id :- su/IntGreaterThanZeroPlumatic] [_ database-id :- su/IntGreaterThanZero]
{:metadata [[:started_at {:display_name "Viewed on", :base_type :type/DateTime}] {:metadata [[:started_at {:display_name "Viewed on", :base_type :type/DateTime}]
[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :query}] [:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :query}]
[:query_hash {:display_name "Query Hash", :base_type :type/Text}] [:query_hash {:display_name "Query Hash", :base_type :type/Text}]
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
;; Details about a specific query (currently just average execution time). ;; Details about a specific query (currently just average execution time).
(s/defmethod audit.i/internal-query ::details (s/defmethod audit.i/internal-query ::details
[_ query-hash :- su/NonBlankStringPlumatic] [_ query-hash :- su/NonBlankString]
{:metadata [[:query {:display_name "Query", :base_type :type/Dictionary}] {:metadata [[:query {:display_name "Query", :base_type :type/Dictionary}]
[:average_execution_time {:display_name "Avg. Exec. Time (ms)", :base_type :type/Number}]] [:average_execution_time {:display_name "Avg. Exec. Time (ms)", :base_type :type/Number}]]
:results (common/reducible-query :results (common/reducible-query
......
...@@ -10,25 +10,25 @@ ...@@ -10,25 +10,25 @@
;; Get views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`. ;; Get views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`.
(s/defmethod audit.i/internal-query ::views-by-time (s/defmethod audit.i/internal-query ::views-by-time
[_ card-id :- su/IntGreaterThanZeroPlumatic datetime-unit :- common/DateTimeUnitStr] [_ card-id :- su/IntGreaterThanZero datetime-unit :- common/DateTimeUnitStr]
(card-and-dash-detail/views-by-time "card" card-id datetime-unit)) (card-and-dash-detail/views-by-time "card" card-id datetime-unit))
;; Get cached views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`. ;; Get cached views of a Card broken out by a time `unit`, e.g. `day` or `day-of-week`.
(s/defmethod audit.i/internal-query ::cached-views-by-time (s/defmethod audit.i/internal-query ::cached-views-by-time
[_ card-id :- su/IntGreaterThanZeroPlumatic, datetime-unit :- common/DateTimeUnitStr] [_ card-id :- su/IntGreaterThanZero, datetime-unit :- common/DateTimeUnitStr]
(card-and-dash-detail/cached-views-by-time card-id datetime-unit)) (card-and-dash-detail/cached-views-by-time card-id datetime-unit))
;; Get the revision history for a Card. ;; Get the revision history for a Card.
(s/defmethod audit.i/internal-query ::revision-history (s/defmethod audit.i/internal-query ::revision-history
[_ card-id :- su/IntGreaterThanZeroPlumatic] [_ card-id :- su/IntGreaterThanZero]
(card-and-dash-detail/revision-history Card card-id)) (card-and-dash-detail/revision-history Card card-id))
;; Get a view log for a Card. ;; Get a view log for a Card.
(s/defmethod audit.i/internal-query ::audit-log (s/defmethod audit.i/internal-query ::audit-log
[_ card-id :- su/IntGreaterThanZeroPlumatic] [_ card-id :- su/IntGreaterThanZero]
(card-and-dash-detail/audit-log "card" card-id)) (card-and-dash-detail/audit-log "card" card-id))
;; Average execution time broken out by period ;; Average execution time broken out by period
(s/defmethod audit.i/internal-query ::avg-execution-time-by-time (s/defmethod audit.i/internal-query ::avg-execution-time-by-time
[_ card-id :- su/IntGreaterThanZeroPlumatic datetime-unit :- common/DateTimeUnitStr] [_ card-id :- su/IntGreaterThanZero datetime-unit :- common/DateTimeUnitStr]
(card-and-dash-detail/avg-execution-time-by-time card-id datetime-unit)) (card-and-dash-detail/avg-execution-time-by-time card-id datetime-unit))
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
;; View log for a specific Table. ;; View log for a specific Table.
(s/defmethod audit.i/internal-query ::audit-log (s/defmethod audit.i/internal-query ::audit-log
[_ table-id :- su/IntGreaterThanZeroPlumatic] [_ table-id :- su/IntGreaterThanZero]
{:metadata [[:started_at {:display_name "Viewed on", :base_type :type/DateTime}] {:metadata [[:started_at {:display_name "Viewed on", :base_type :type/DateTime}]
[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :query}] [:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :query}]
[:query {:display_name "Query", :base_type :type/Text, :remapped_from :card_id}] [:query {:display_name "Query", :base_type :type/Text, :remapped_from :card_id}]
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
;; ;;
;; (TODO - in the designs, this is pivoted; should we do that here in Clojure-land?) ;; (TODO - in the designs, this is pivoted; should we do that here in Clojure-land?)
(s/defmethod audit.i/internal-query ::table (s/defmethod audit.i/internal-query ::table
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:name {:display_name "Name", :base_type :type/Name}] {:metadata [[:name {:display_name "Name", :base_type :type/Name}]
[:role {:display_name "Role", :base_type :type/Text}] [:role {:display_name "Role", :base_type :type/Text}]
[:groups {:display_name "Groups", :base_type :type/Text}] [:groups {:display_name "Groups", :base_type :type/Text}]
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
;; Return the 10 most-viewed Dashboards for a given User, in descending order. ;; Return the 10 most-viewed Dashboards for a given User, in descending order.
(s/defmethod audit.i/internal-query ::most-viewed-dashboards (s/defmethod audit.i/internal-query ::most-viewed-dashboards
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:dashboard_id {:display_name "Dashboard ID", :base_type :type/Integer, :remapped_to :dashboard_name}] {:metadata [[:dashboard_id {:display_name "Dashboard ID", :base_type :type/Integer, :remapped_to :dashboard_name}]
[:dashboard_name {:display_name "Dashboard", :base_type :type/Name, :remapped_from :dashboard_id}] [:dashboard_name {:display_name "Dashboard", :base_type :type/Name, :remapped_from :dashboard_id}]
[:count {:display_name "Views", :base_type :type/Integer}]] [:count {:display_name "Views", :base_type :type/Integer}]]
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
;; Return the 10 most-viewed Questions for a given User, in descending order. ;; Return the 10 most-viewed Questions for a given User, in descending order.
(s/defmethod audit.i/internal-query ::most-viewed-questions (s/defmethod audit.i/internal-query ::most-viewed-questions
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}] {:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}]
[:card_name {:display_name "Query", :base_type :type/Name, :remapped_from :card_id}] [:card_name {:display_name "Query", :base_type :type/Name, :remapped_from :card_id}]
[:count {:display_name "Views", :base_type :type/Integer}]] [:count {:display_name "Views", :base_type :type/Integer}]]
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
;; Query views by a specific User. ;; Query views by a specific User.
(s/defmethod audit.i/internal-query ::query-views (s/defmethod audit.i/internal-query ::query-views
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:viewed_on {:display_name "Viewed On", :base_type :type/DateTime}] {:metadata [[:viewed_on {:display_name "Viewed On", :base_type :type/DateTime}]
[:card_id {:display_name "Card ID" :base_type :type/Integer, :remapped_to :card_name}] [:card_id {:display_name "Card ID" :base_type :type/Integer, :remapped_to :card_name}]
[:card_name {:display_name "Query", :base_type :type/Text, :remapped_from :card_id}] [:card_name {:display_name "Query", :base_type :type/Text, :remapped_from :card_id}]
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
;; Dashboard views by a specific User. ;; Dashboard views by a specific User.
(s/defmethod audit.i/internal-query ::dashboard-views (s/defmethod audit.i/internal-query ::dashboard-views
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:timestamp {:display_name "Viewed on", :base_type :type/DateTime}] {:metadata [[:timestamp {:display_name "Viewed on", :base_type :type/DateTime}]
[:dashboard_id {:display_name "Dashboard ID", :base_type :type/Integer, :remapped_to :dashboard_name}] [:dashboard_id {:display_name "Dashboard ID", :base_type :type/Integer, :remapped_to :dashboard_name}]
[:dashboard_name {:display_name "Dashboard", :base_type :type/Text, :remapped_from :dashboard_id}] [:dashboard_name {:display_name "Dashboard", :base_type :type/Text, :remapped_from :dashboard_id}]
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
;; Timeseries chart that shows the number of Question or Dashboard views for a User, broken out by `datetime-unit`. ;; Timeseries chart that shows the number of Question or Dashboard views for a User, broken out by `datetime-unit`.
(s/defmethod audit.i/internal-query ::object-views-by-time (s/defmethod audit.i/internal-query ::object-views-by-time
[_ [_
user-id :- su/IntGreaterThanZeroPlumatic user-id :- su/IntGreaterThanZero
model :- (s/enum "card" "dashboard") model :- (s/enum "card" "dashboard")
datetime-unit :- common/DateTimeUnitStr] datetime-unit :- common/DateTimeUnitStr]
{:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type datetime-unit)}] {:metadata [[:date {:display_name "Date", :base_type (common/datetime-unit-str->base-type datetime-unit)}]
...@@ -199,12 +199,12 @@ ...@@ -199,12 +199,12 @@
(s/defmethod audit.i/internal-query ::created-dashboards (s/defmethod audit.i/internal-query ::created-dashboards
([query-type user-id] ([query-type user-id]
(audit.i/internal-query query-type user-id nil)) (audit.i/internal-query query-type user-id nil))
([_ user-id :- su/IntGreaterThanZeroPlumatic query-string :- (s/maybe s/Str)] ([_ user-id :- su/IntGreaterThanZero query-string :- (s/maybe s/Str)]
(dashboards/table query-string [:= :u.id user-id]))) (dashboards/table query-string [:= :u.id user-id])))
;; Questions created by a specific User. ;; Questions created by a specific User.
(s/defmethod audit.i/internal-query ::created-questions (s/defmethod audit.i/internal-query ::created-questions
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}] {:metadata [[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}]
[:card_name {:display_name "Title", :base_type :type/Name, :remapped_from :card_id}] [:card_name {:display_name "Title", :base_type :type/Name, :remapped_from :card_id}]
[:collection_id {:display_name "Collection ID", :base_type :type/Integer, :remapped_to :collection_name}] [:collection_id {:display_name "Collection ID", :base_type :type/Integer, :remapped_to :collection_name}]
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
;; Table of query downloads (i.e., queries whose results are returned as CSV/JSON/XLS) done by this user, ordered by ;; Table of query downloads (i.e., queries whose results are returned as CSV/JSON/XLS) done by this user, ordered by
;; most recent. ;; most recent.
(s/defmethod audit.i/internal-query ::downloads (s/defmethod audit.i/internal-query ::downloads
[_ user-id :- su/IntGreaterThanZeroPlumatic] [_ user-id :- su/IntGreaterThanZero]
{:metadata [[:downloaded_at {:display_name "Downloaded At", :base_type :type/DateTime}] {:metadata [[:downloaded_at {:display_name "Downloaded At", :base_type :type/DateTime}]
[:rows_downloaded {:display_name "Rows Downloaded", :base_type :type/Integer}] [:rows_downloaded {:display_name "Rows Downloaded", :base_type :type/Integer}]
[:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}] [:card_id {:display_name "Card ID", :base_type :type/Integer, :remapped_to :card_name}]
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
(for [[k v] metadata] (for [[k v] metadata]
(assoc v :name (name k)))) (assoc v :name (name k))))
(s/defn ^:private format-results [{:keys [results metadata]} :- {:results [su/MapPlumatic] (s/defn ^:private format-results [{:keys [results metadata]} :- {:results [su/Map]
:metadata audit.i/ResultsMetadata}] :metadata audit.i/ResultsMetadata}]
(check-results-and-metadata-keys-match results metadata) (check-results-and-metadata-keys-match results metadata)
{:cols (metadata->cols metadata) {:cols (metadata->cols metadata)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"Create a new `ModerationReview`." "Create a new `ModerationReview`."
[:as {{:keys [text moderated_item_id moderated_item_type status]} :body}] [:as {{:keys [text moderated_item_id moderated_item_type status]} :body}]
{text (s/maybe s/Str) {text (s/maybe s/Str)
moderated_item_id su/IntGreaterThanZeroPlumatic moderated_item_id su/IntGreaterThanZero
moderated_item_type moderation/moderated-item-types moderated_item_type moderation/moderated-item-types
status moderation-review/Statuses} status moderation-review/Statuses}
(api/check-superuser) (api/check-superuser)
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"Get user information for the supplied username." "Get user information for the supplied username."
:feature :any :feature :any
[ldap-connection :- LDAPConnectionPool [ldap-connection :- LDAPConnectionPool
username :- su/NonBlankStringPlumatic username :- su/NonBlankString
settings :- i/LDAPSettings] settings :- i/LDAPSettings]
(when-let [result (default-impl/search ldap-connection username settings)] (when-let [result (default-impl/search ldap-connection username settings)]
(when-let [user-info (default-impl/ldap-search-result->user-info (when-let [user-info (default-impl/ldap-search-result->user-info
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
[toucan.db :as db])) [toucan.db :as db]))
(s/defn ^:private has-parent-collection-perms? (s/defn ^:private has-parent-collection-perms?
[snippet :- {:collection_id (s/maybe su/IntGreaterThanZeroPlumatic), s/Keyword s/Any} [snippet :- {:collection_id (s/maybe su/IntGreaterThanZero), s/Keyword s/Any}
read-or-write :- (s/enum :read :write)] read-or-write :- (s/enum :read :write)]
(mi/current-user-has-full-permissions? (perms/perms-objects-set-for-parent-collection "snippets" snippet read-or-write))) (mi/current-user-has-full-permissions? (perms/perms-objects-set-for-parent-collection "snippets" snippet read-or-write)))
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
(api/defendpoint-schema POST "/" (api/defendpoint-schema POST "/"
"Create a new GTAP." "Create a new GTAP."
[:as {{:keys [table_id card_id group_id attribute_remappings]} :body}] [:as {{:keys [table_id card_id group_id attribute_remappings]} :body}]
{table_id su/IntGreaterThanZeroPlumatic {table_id su/IntGreaterThanZero
card_id (s/maybe su/IntGreaterThanZeroPlumatic) card_id (s/maybe su/IntGreaterThanZero)
group_id su/IntGreaterThanZeroPlumatic group_id su/IntGreaterThanZero
#_attribute_remappings #_AttributeRemappings} ; TODO - fix me #_attribute_remappings #_AttributeRemappings} ; TODO - fix me
(db/insert! GroupTableAccessPolicy (db/insert! GroupTableAccessPolicy
{:table_id table_id {:table_id table_id
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
paramter mappings; changing `table_id` or `group_id` would effectively be deleting this entry and creating a new paramter mappings; changing `table_id` or `group_id` would effectively be deleting this entry and creating a new
one. If that's what you want to do, do so explicity with appropriate calls to the `DELETE` and `POST` endpoints." one. If that's what you want to do, do so explicity with appropriate calls to the `DELETE` and `POST` endpoints."
[id :as {{:keys [card_id #_attribute_remappings], :as body} :body}] [id :as {{:keys [card_id #_attribute_remappings], :as body} :body}]
{card_id (s/maybe su/IntGreaterThanZeroPlumatic) {card_id (s/maybe su/IntGreaterThanZero)
#_attribute_remappings #_AttributeRemappings} ; TODO - fix me #_attribute_remappings #_AttributeRemappings} ; TODO - fix me
(api/check-404 (GroupTableAccessPolicy id)) (api/check-404 (GroupTableAccessPolicy id))
;; Only update `card_id` and/or `attribute_remappings` if the values are present in the body of the request. ;; Only update `card_id` and/or `attribute_remappings` if the values are present in the body of the request.
......
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
doesn't add/change anything from the OSS version. See the docs on the OSS version of the endpoint for more doesn't add/change anything from the OSS version. See the docs on the OSS version of the endpoint for more
information." information."
[id include_sensitive_fields include_hidden_fields include_editable_data_model] [id include_sensitive_fields include_hidden_fields include_editable_data_model]
{include_sensitive_fields (s/maybe su/BooleanStringPlumatic) {include_sensitive_fields (s/maybe su/BooleanString)
include_hidden_fields (s/maybe su/BooleanStringPlumatic) include_hidden_fields (s/maybe su/BooleanString)
include_editable_data_model (s/maybe su/BooleanStringPlumatic)} include_editable_data_model (s/maybe su/BooleanString)}
(let [table (api/check-404 (db/select-one Table :id id)) (let [table (api/check-404 (db/select-one Table :id id))
segmented-perms? (only-segmented-perms? table) segmented-perms? (only-segmented-perms? table)
thunk (fn [] thunk (fn []
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
[toucan.db :as db])) [toucan.db :as db]))
(def ^:private UserAttributes (def ^:private UserAttributes
(su/with-api-error-message (s/maybe {su/NonBlankStringPlumatic s/Any}) (su/with-api-error-message (s/maybe {su/NonBlankString s/Any})
"value must be a valid user attributes map (name -> value)")) "value must be a valid user attributes map (name -> value)"))
;; TODO - not sure we need this endpoint now that we're just letting you edit from the regular `PUT /api/user/:id ;; TODO - not sure we need this endpoint now that we're just letting you edit from the regular `PUT /api/user/:id
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
(when-let [result-metadata (db/select-one-field :result_metadata Card :id card-id)] (when-let [result-metadata (db/select-one-field :result_metadata Card :id card-id)]
(check-columns-match-table table-id result-metadata)))) (check-columns-match-table table-id result-metadata))))
([table-id :- su/IntGreaterThanZeroPlumatic result-metadata-columns] ([table-id :- su/IntGreaterThanZero result-metadata-columns]
;; prevent circular refs ;; prevent circular refs
(classloader/require 'metabase.query-processor) (classloader/require 'metabase.query-processor)
(let [table-cols (table-field-names->cols table-id)] (let [table-cols (table-field-names->cols table-id)]
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
;;; | Applying a GTAP | ;;; | Applying a GTAP |
;;; +----------------------------------------------------------------------------------------------------------------+ ;;; +----------------------------------------------------------------------------------------------------------------+
(s/defn ^:private target-field->base-type :- (s/maybe su/FieldTypePlumatic) (s/defn ^:private target-field->base-type :- (s/maybe su/FieldType)
"If the `:target` of a parameter contains a `:field` clause, return the base type corresponding to the Field it "If the `:target` of a parameter contains a `:field` clause, return the base type corresponding to the Field it
references. Otherwise returns `nil`." references. Otherwise returns `nil`."
[[_ target-field-clause]] [[_ target-field-clause]]
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
(defn- table-gtap->source [{table-id :table_id, :as gtap}] (defn- table-gtap->source [{table-id :table_id, :as gtap}]
{:source-query {:source-table table-id, :parameters (gtap->parameters gtap)}}) {:source-query {:source-table table-id, :parameters (gtap->parameters gtap)}})
(s/defn ^:private mbql-query-metadata :- (su/non-empty [su/MapPlumatic]) (s/defn ^:private mbql-query-metadata :- (su/non-empty [su/Map])
[inner-query] [inner-query]
(binding [api/*current-user-permissions-set* (atom #{"/"})] (binding [api/*current-user-permissions-set* (atom #{"/"})]
((requiring-resolve 'metabase.query-processor/query->expected-cols) ((requiring-resolve 'metabase.query-processor/query->expected-cols)
...@@ -177,9 +177,9 @@ ...@@ -177,9 +177,9 @@
(mbql-query-metadata {:source-table table-id})) (mbql-query-metadata {:source-table table-id}))
:ttl/threshold (u/minutes->ms 1))) :ttl/threshold (u/minutes->ms 1)))
(s/defn ^:private reconcile-metadata :- (su/non-empty [su/MapPlumatic]) (s/defn ^:private reconcile-metadata :- (su/non-empty [su/Map])
"Combine the metadata in `source-query-metadata` with the `table-metadata` from the Table being sandboxed." "Combine the metadata in `source-query-metadata` with the `table-metadata` from the Table being sandboxed."
[source-query-metadata :- (su/non-empty [su/MapPlumatic]) table-metadata] [source-query-metadata :- (su/non-empty [su/Map]) table-metadata]
(let [col-name->table-metadata (m/index-by :name table-metadata)] (let [col-name->table-metadata (m/index-by :name table-metadata)]
(vec (vec
(for [col source-query-metadata (for [col source-query-metadata
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
(gtap/check-column-types-match col table-col) (gtap/check-column-types-match col table-col)
table-col))))) table-col)))))
(s/defn ^:private native-query-metadata :- (su/non-empty [su/MapPlumatic]) (s/defn ^:private native-query-metadata :- (su/non-empty [su/Map])
[source-query :- {:source-query s/Any, s/Keyword s/Any}] [source-query :- {:source-query s/Any, s/Keyword s/Any}]
(let [result (binding [api/*current-user-permissions-set* (atom #{"/"})] (let [result (binding [api/*current-user-permissions-set* (atom #{"/"})]
((requiring-resolve 'metabase.query-processor/process-query) ((requiring-resolve 'metabase.query-processor/process-query)
...@@ -203,13 +203,13 @@ ...@@ -203,13 +203,13 @@
:result result}))))) :result result})))))
(s/defn ^:private source-query-form-ensure-metadata :- {:source-query s/Any (s/defn ^:private source-query-form-ensure-metadata :- {:source-query s/Any
:source-metadata (su/non-empty [su/MapPlumatic]) :source-metadata (su/non-empty [su/Map])
s/Keyword s/Any} s/Keyword s/Any}
"Add `:source-metadata` to a `source-query` if needed. If the source metadata had to be resolved (because Card with "Add `:source-metadata` to a `source-query` if needed. If the source metadata had to be resolved (because Card with
`card-id`) didn't already have it, save it so we don't have to resolve it again next time around." `card-id`) didn't already have it, save it so we don't have to resolve it again next time around."
[{:keys [source-metadata], :as source-query} :- {:source-query s/Any, s/Keyword s/Any} [{:keys [source-metadata], :as source-query} :- {:source-query s/Any, s/Keyword s/Any}
table-id :- su/IntGreaterThanZeroPlumatic table-id :- su/IntGreaterThanZero
card-id :- (s/maybe su/IntGreaterThanZeroPlumatic)] card-id :- (s/maybe su/IntGreaterThanZero)]
(let [table-metadata (original-table-metadata table-id) (let [table-metadata (original-table-metadata table-id)
;; make sure source query has `:source-metadata`; add it if needed ;; make sure source query has `:source-metadata`; add it if needed
[metadata save?] (cond [metadata save?] (cond
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
(s/optional-key :source-metadata) [mbql.s/SourceQueryMetadata] (s/optional-key :source-metadata) [mbql.s/SourceQueryMetadata]
s/Keyword s/Any} s/Keyword s/Any}
"Get the source query associated with a `gtap`." "Get the source query associated with a `gtap`."
[{card-id :card_id, table-id :table_id, :as gtap} :- su/MapPlumatic] [{card-id :card_id, table-id :table_id, :as gtap} :- su/Map]
(-> ((if card-id (-> ((if card-id
card-gtap->source card-gtap->source
table-gtap->source) gtap) table-gtap->source) gtap)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment