Skip to content

Commit

Permalink
Hide system attrs from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
nezaj committed Feb 19, 2025
1 parent 38b1e1d commit f66549f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 6 additions & 2 deletions server/src/instant/db/model/attr.clj
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,12 @@
"Removes the system attrs that might be confusing for the users."
[^Attrs attrs]
(remove (fn [a]
(and (= :system (:catalog a))
(not (#{"$users" "$files"} (fwd-etype a)))))
(or
(and (= :system (:catalog a))
(not (#{"$users" "$files"} (fwd-etype a))))
(and (= "$files" (fwd-etype a))
(#{"content-type" "content-disposition" "size"
"location-id" "key-version"} (fwd-label a)))))
attrs))

(defn resolve-attr-id [attrs etype label]
Expand Down
19 changes: 17 additions & 2 deletions server/src/instant/model/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@
attrs)))))]
{:refs refs-indexed :blobs blobs-indexed}))

(defn filter-indexed-blobs
[coll-name attrs-map]
(let [attrs-seq (for [[_attr-name attr-def] attrs-map]
(assoc attr-def
:catalog (if (.startsWith (name coll-name) "$") :system :user)))
filtered-seq (attr-model/remove-hidden (attr-model/wrap-attrs attrs-seq))]
(into {}
(for [attr filtered-seq]
[(-> attr :forward-identity (nth 2) keyword) (dissoc attr :catalog)]))))

(defn defs->schema [defs]
(let [{entities :entities links :links} defs
refs-indexed (into {} (map (fn [[_ {:keys [forward reverse]}]]
Expand All @@ -167,9 +177,14 @@
(when (contains? attr-model/checked-data-types valueType)
(keyword valueType)))})
(:attrs def)))
entities)]
entities)
blobs-filtered (into {}
(for [[coll-name attrs-map] blobs-indexed
:let [filtered-attrs (filter-indexed-blobs coll-name attrs-map)]
:when (seq filtered-attrs)]
[coll-name filtered-attrs]))]
{:refs refs-indexed
:blobs blobs-indexed}))
:blobs blobs-filtered}))

(defn dup-message [[etype label]]
(str etype "->" label ": "
Expand Down

0 comments on commit f66549f

Please sign in to comment.