enhance: get_tag_objects support either block/uuid or db ident

This commit is contained in:
Tienson Qin
2025-10-09 14:26:43 +08:00
parent 698cb36972
commit 20f8f0fa80
3 changed files with 11 additions and 7 deletions

View File

@@ -1187,8 +1187,8 @@
(db-api/remove-property property))))
(def ^:export get_all_tags db-api/get-all-tags)
(def ^:export get-all-properties db-api/get-all-properties)
(def ^:export get-tag-objects db-api/get-tag-objects)
(def ^:export get_all_properties db-api/get-all-properties)
(def ^:export get_tag_objects db-api/get-tag-objects)
;; file based graph APIs
(def ^:export get_current_graph_templates file-api/get_current_graph_templates)

View File

@@ -11,6 +11,7 @@
[frontend.handler.page :as page-handler]
[frontend.modules.layout.core]
[frontend.state :as state]
[frontend.util :as util]
[logseq.api.block :as api-block]
[logseq.db :as ldb]
[logseq.outliner.core :as outliner-core]
@@ -109,11 +110,14 @@
result->js))
(defn get-tag-objects
[class-uuid]
(let [id (sdk-utils/uuid-or-throw-error class-uuid)
class (db/entity [:block/uuid id])]
[class-uuid-or-ident]
(let [eid (if (util/uuid-string? class-uuid-or-ident)
(when-let [id (sdk-utils/uuid-or-throw-error class-uuid-or-ident)]
[:block/uuid id])
(keyword (api-block/sanitize-user-property-name class-uuid-or-ident)))
class (db/entity eid)]
(if-not class
(throw (ex-info (str "Tag not exists with id: " class-uuid) {}))
(throw (ex-info (str "Tag not exists with id: " eid) {}))
(p/let [result (state/<invoke-db-worker :thread-api/get-class-objects
(state/get-current-repo)
(:db/id class))]

View File

@@ -19,7 +19,7 @@
[m]
(->> (remove (fn [[k _v]]
(or (= "block.temp" (namespace k))
(contains? #{:logseq.property.embedding/hnsw-label-updated-at} k))) m)
(contains? #{:logseq.property.embedding/hnsw-label-updated-at :block/tx-id} k))) m)
(into {})))
(defn normalize-keyword-for-json