fix: markdown tables didn't recognize built-in v2 properties

also fix enum values not usable for api fn
This commit is contained in:
Gabriel Horner
2023-10-23 12:28:55 -04:00
parent a2e27a0007
commit 2c1ccf99dc
4 changed files with 23 additions and 14 deletions

View File

@@ -65,4 +65,20 @@
(defn enum-value
"Given an enum ent and the value's uuid, return the value's string"
[ent value-uuid]
(get-in ent [:block/schema :enum-config :values value-uuid :name]))
(get-in ent [:block/schema :enum-config :values value-uuid :name]))
(defn readable-properties
"Given a DB graph's properties, returns a readable properties map with keys as
property names and property values dereferenced where possible. A property's
value will only be a uuid if it's a page or a block"
[properties]
(->> properties
(map (fn [[k v]]
(let [prop-ent (db/entity [:block/uuid k])]
[(-> prop-ent
:block/name
keyword)
(if (= :enum (get-in prop-ent [:block/schema :type]))
(enum-value prop-ent v)
v)])))
(into {})))