From 37af8f690e4b9393fdbd2f3317cdc2cd8e0b71c0 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Mon, 12 Jan 2026 12:20:51 -0500 Subject: [PATCH] fix: remove remaining uses of file graph specific attributes Removed all file graph uses of :block/namespace, :block/file, :block/type and :block/properties except for graph-parser which still uses them for db importer. Removed all uses of :block/format except for graph-parser and src/main/frontend --- .../src/logseq/cli/common/export/common.cljs | 6 +- deps/cli/src/logseq/cli/common/file.cljs | 2 +- deps/cli/src/logseq/cli/common/mcp/tools.cljs | 3 +- deps/db/README.md | 1 - deps/db/script/query.cljs | 4 +- deps/db/src/logseq/db.cljs | 37 ++++-------- .../src/logseq/db/common/property_util.cljs | 18 +++--- deps/db/src/logseq/db/frontend/class.cljs | 3 +- deps/outliner/src/logseq/outliner/core.cljs | 26 ++++----- .../src/logseq/outliner/property.cljs | 2 +- deps/outliner/src/logseq/outliner/tree.cljs | 8 +-- deps/publishing/src/logseq/publishing/db.cljs | 3 +- docs/dev-practices.md | 30 +++------- src/main/frontend/common_keywords.cljs | 1 - src/main/frontend/components/block.cljs | 3 +- src/main/frontend/db/model.cljs | 57 +++++++------------ src/main/frontend/format/block.cljs | 4 +- src/main/frontend/handler/export/common.cljs | 8 +-- src/main/frontend/handler/property/util.cljs | 15 ++--- src/main/frontend/modules/outliner/tree.cljs | 2 +- src/main/frontend/worker/db_worker.cljs | 5 -- src/main/frontend/worker/export.cljs | 40 +------------ src/test/frontend/worker/rtc/client_test.cljs | 19 ++----- 23 files changed, 90 insertions(+), 207 deletions(-) diff --git a/deps/cli/src/logseq/cli/common/export/common.cljs b/deps/cli/src/logseq/cli/common/export/common.cljs index a400974fc0..0f131c5234 100644 --- a/deps/cli/src/logseq/cli/common/export/common.cljs +++ b/deps/cli/src/logseq/cli/common/export/common.cljs @@ -61,14 +61,14 @@ ;;; internal utils (defn ^:api get-blocks-contents - [repo root-block-uuid & {:keys [init-level] + [root-block-uuid & {:keys [init-level] :or {init-level 1}}] (let [block (d/entity *current-db* [:block/uuid root-block-uuid]) link (:block/link block) block' (or link block) root-id (:block/uuid block') blocks (ldb/get-block-and-children *current-db* root-id) - tree (otree/blocks->vec-tree repo *current-db* blocks root-id {:link link})] + tree (otree/blocks->vec-tree *current-db* blocks root-id {:link link})] (common-file/tree->file-content *current-repo* *current-db* tree {:init-level init-level :link link} *content-config*))) @@ -87,7 +87,7 @@ (defn- block-uuid->ast-with-children [block-uuid] - (let [content (get-blocks-contents *current-repo* block-uuid) + (let [content (get-blocks-contents block-uuid) format :markdown] (when content (removev Properties-block-ast? diff --git a/deps/cli/src/logseq/cli/common/file.cljs b/deps/cli/src/logseq/cli/common/file.cljs index 6887d313dd..aa14d53528 100644 --- a/deps/cli/src/logseq/cli/common/file.cljs +++ b/deps/cli/src/logseq/cli/common/file.cljs @@ -89,7 +89,7 @@ 1)) blocks (->> (d/pull-many db '[*] (keep :db/id (ldb/get-block-and-children db root-block-uuid))) (map #(update-block-content db % (:db/id %)))) - tree (otree/blocks->vec-tree repo db blocks (str root-block-uuid))] + tree (otree/blocks->vec-tree db blocks (str root-block-uuid))] (tree->file-content repo db tree (assoc tree->file-opts :init-level init-level) context))) diff --git a/deps/cli/src/logseq/cli/common/mcp/tools.cljs b/deps/cli/src/logseq/cli/common/mcp/tools.cljs index a40ed0d767..5ed4503064 100644 --- a/deps/cli/src/logseq/cli/common/mcp/tools.cljs +++ b/deps/cli/src/logseq/cli/common/mcp/tools.cljs @@ -74,8 +74,7 @@ block-eids (mapv :e datoms) block-ents (map #(d/entity db %) block-eids) blocks (map #(assoc % :block/title (db-content/recur-replace-uuid-in-block-title %)) block-ents)] - ;; Use repo stub since this is a DB only tool - (->> (otree/blocks->vec-tree "logseq_db_repo_stub" db blocks page-id) + (->> (otree/blocks->vec-tree db blocks page-id) (map #(update % :block/uuid str))))) (defn ^:api remove-hidden-properties diff --git a/deps/db/README.md b/deps/db/README.md index 7bcd3f73d9..2561275a25 100644 --- a/deps/db/README.md +++ b/deps/db/README.md @@ -15,7 +15,6 @@ This library is under the parent namespace `logseq.db`. It provides the followin * `logseq.db` - main entry point serving both file and DB graphs * `logseq.db.frontend.*` - frontend namespaces for DB graphs * `logseq.db.sqlite.*` - backend/sqlite namespaces for DB graphs -* `logseq.db.file-based.*` - namespaces for file graphs, mostly old namespaces * `logseq.db.common.*` - namespaces for both file and DB graphs ## Usage diff --git a/deps/db/script/query.cljs b/deps/db/script/query.cljs index e6537333e4..5b7b8df4f2 100644 --- a/deps/db/script/query.cljs +++ b/deps/db/script/query.cljs @@ -39,9 +39,7 @@ results (if (:entity options) (map #(when-let [ent (d/entity @conn (if (string? %) (edn/read-string %) %))] - (cond-> (into {:db/id (:db/id ent)} ent) - (seq (:block/properties ent)) - (update :block/properties (fn [props] (map (fn [m] (into {} m)) props))))) + (into {:db/id (:db/id ent)} ent)) (:entity options)) ;; assumes no :in are in queries (let [query (into (edn/read-string (first args'')) [:in '$ '%]) diff --git a/deps/db/src/logseq/db.cljs b/deps/db/src/logseq/db.cljs index b87ed030ab..a4589b26e0 100644 --- a/deps/db/src/logseq/db.cljs +++ b/deps/db/src/logseq/db.cljs @@ -421,7 +421,6 @@ (contains? #{"" "-" "*"} (string/trim (:block/title first-child)))))) (not (contains? built-in-pages name')) (not (whiteboard? page)) - (not (:block/_namespace page)) (not (property? page)) ;; a/b/c might be deleted but a/b/c/d still exists (for backward compatibility) (not (and (string/includes? name' "/") @@ -620,30 +619,18 @@ (defn get-pages-relation [db with-journal?] - (if (entity-plus/db-based-graph? db) - (let [q (if with-journal? - '[:find ?p ?ref-page - :where - [?block :block/page ?p] - [?block :block/refs ?ref-page]] - '[:find ?p ?ref-page - :where - [?block :block/page ?p] - [?p :block/tags] - (not [?p :block/tags :logseq.class/Journal]) - [?block :block/refs ?ref-page]])] - (d/q q db)) - (let [q (if with-journal? - '[:find ?p ?ref-page - :where - [?block :block/page ?p] - [?block :block/refs ?ref-page]] - '[:find ?p ?ref-page - :where - [?block :block/page ?p] - (not [?p :block/type "journal"]) - [?block :block/refs ?ref-page]])] - (d/q q db)))) + (let [q (if with-journal? + '[:find ?p ?ref-page + :where + [?block :block/page ?p] + [?block :block/refs ?ref-page]] + '[:find ?p ?ref-page + :where + [?block :block/page ?p] + [?p :block/tags] + (not [?p :block/tags :logseq.class/Journal]) + [?block :block/refs ?ref-page]])] + (d/q q db))) (defn get-all-tagged-pages [db] diff --git a/deps/db/src/logseq/db/common/property_util.cljs b/deps/db/src/logseq/db/common/property_util.cljs index 58ea24f5d2..80c70af5bc 100644 --- a/deps/db/src/logseq/db/common/property_util.cljs +++ b/deps/db/src/logseq/db/common/property_util.cljs @@ -25,20 +25,18 @@ (get-file-pid db-ident))) (defn lookup - "Get the property value by a built-in property's db-ident from coll. For file and db graphs" - [repo block db-ident] - (if (sqlite-util/db-based-graph? repo) - (let [val (get block db-ident)] - (if (db-property/built-in-has-ref-value? db-ident) (db-property/property-value-content val) val)) - (get (:block/properties block) (get-pid repo db-ident)))) + "Get the property value by a built-in property's db-ident from coll" + [block db-ident] + (let [val (get block db-ident)] + (if (db-property/built-in-has-ref-value? db-ident) (db-property/property-value-content val) val))) (defn get-block-property-value "Get the value of built-in block's property by its db-ident" - [repo db block db-ident] + [db block db-ident] (when db (let [block (or (d/entity db (:db/id block)) block)] - (lookup repo block db-ident)))) + (lookup block db-ident)))) (defn shape-block? - [repo db block] - (= :whiteboard-shape (get-block-property-value repo db block :logseq.property/ls-type))) + [db block] + (= :whiteboard-shape (get-block-property-value db block :logseq.property/ls-type))) diff --git a/deps/db/src/logseq/db/frontend/class.cljs b/deps/db/src/logseq/db/frontend/class.cljs index b1e55fdb7c..05c2b5cdf7 100644 --- a/deps/db/src/logseq/db/frontend/class.cljs +++ b/deps/db/src/logseq/db/frontend/class.cljs @@ -111,8 +111,7 @@ :logseq.class/Asset}) (def private-tags - "Built-in classes that are private and should not be used by a user directly. - These used to be in block/type" + "Built-in classes that are private and should not be used by a user directly." (set/union (disj internal-tags :logseq.class/Root) #{:logseq.class/Journal :logseq.class/Whiteboard :logseq.class/Pdf-annotation})) diff --git a/deps/outliner/src/logseq/outliner/core.cljs b/deps/outliner/src/logseq/outliner/core.cljs index 7e918e33d8..f1c3a0435c 100644 --- a/deps/outliner/src/logseq/outliner/core.cljs +++ b/deps/outliner/src/logseq/outliner/core.cljs @@ -243,8 +243,7 @@ (let [data (if (de/entity? this) (assoc (.-kv ^js this) :db/id (:db/id this)) this) - data' (->> (dissoc data :block/properties) - (remove-disallowed-inline-classes db)) + data' (remove-disallowed-inline-classes db data) collapse-or-expand? (= outliner-op :collapse-expand-blocks) m* (cond-> (-> data' @@ -268,19 +267,16 @@ (not= block-title (:block/title block-entity))) _ (when (and page? block-title) (outliner-validate/validate-page-title-characters block-title {:node m*})) - m* (if page-title-changed? - (let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*}) - page-name (common-util/page-name-sanity-lc (:block/title m*))] - (assoc m* :block/name page-name)) - m*) + m (if page-title-changed? + (let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*}) + page-name (common-util/page-name-sanity-lc (:block/title m*))] + (assoc m* :block/name page-name)) + m*) _ (when (and ;; page or object changed? (or (ldb/page? block-entity) (ldb/object? block-entity)) - (:block/title m*) - (not= (:block/title m*) (:block/title block-entity))) - (outliner-validate/validate-block-title db (:block/title m*) block-entity)) - m (cond-> m* - true - (dissoc :block/format))] + (:block/title m) + (not= (:block/title m) (:block/title block-entity))) + (outliner-validate/validate-block-title db (:block/title m) block-entity))] ;; Ensure block UUID never changes (let [e (d/entity db db-id)] (when (and e block-uuid) @@ -747,9 +743,7 @@ update-timestamps? (mapv #(dissoc % :block/created-at :block/updated-at)) true - (mapv block-with-timestamps) - true - (mapv #(-> % (dissoc :block/properties))))) + (mapv block-with-timestamps))) insert-opts {:sibling? sibling? :replace-empty-target? replace-empty-target? :keep-uuid? keep-uuid? diff --git a/deps/outliner/src/logseq/outliner/property.cljs b/deps/outliner/src/logseq/outliner/property.cljs index a19ced2da5..4f9785838a 100644 --- a/deps/outliner/src/logseq/outliner/property.cljs +++ b/deps/outliner/src/logseq/outliner/property.cljs @@ -699,7 +699,7 @@ (let [block (d/entity db eid)] (->> (concat - (map (fn [ident] (d/entity db ident)) (keys (:block/properties block))) + (map (fn [ident] (d/entity db ident)) (keys (entity-plus/lookup-kv-then-entity block :block/properties))) (:classes-properties (get-block-classes-properties db eid))) (common-util/distinct-by :db/id)))) diff --git a/deps/outliner/src/logseq/outliner/tree.cljs b/deps/outliner/src/logseq/outliner/tree.cljs index a24275b6f2..aaf2f56a5f 100644 --- a/deps/outliner/src/logseq/outliner/tree.cljs +++ b/deps/outliner/src/logseq/outliner/tree.cljs @@ -10,9 +10,9 @@ (-del [this *txs-state db])) (defn- blocks->vec-tree-aux - [repo db blocks root] + [db blocks root] (let [root-id (:db/id root) - blocks (remove #(db-property-util/shape-block? repo db %) blocks) + blocks (remove #(db-property-util/shape-block? db %) blocks) parent-blocks (group-by #(get-in % [:block/parent :db/id]) blocks) ;; exclude whiteboard shapes sort-fn (fn [parent] (when-let [children (get parent-blocks parent)] @@ -53,14 +53,14 @@ ;; TODO: entity can already be used as a tree (defn blocks->vec-tree "`blocks` need to be in the same page." - [repo db blocks root-id & {:as option}] + [db blocks root-id & {:as option}] (let [blocks (map (fn [b] (if (de/entity? b) (assoc (into {} b) :db/id (:db/id b)) b)) blocks) [page? root] (get-root-and-page db root-id)] (if-not root ; custom query blocks - (let [result (blocks->vec-tree-aux repo db blocks root)] + (let [result (blocks->vec-tree-aux db blocks root)] (if (and page? (not (:link option))) result ;; include root block diff --git a/deps/publishing/src/logseq/publishing/db.cljs b/deps/publishing/src/logseq/publishing/db.cljs index 671c887aec..c52ea491f2 100644 --- a/deps/publishing/src/logseq/publishing/db.cljs +++ b/deps/publishing/src/logseq/publishing/db.cljs @@ -2,6 +2,7 @@ "Provides db fns and associated util fns for publishing" (:require [clojure.set :as set] [datascript.core :as d] + [logseq.db.common.entity-plus :as entity-plus] [logseq.db.frontend.malli-schema :as db-malli-schema] [logseq.db.frontend.rules :as rules])) @@ -25,7 +26,7 @@ (when (seq tag-pages*) (some-> (d/entity db :block/tags) :db/id vector))) property-pages (mapcat (fn [ent] - (->> (keys (:block/properties ent)) + (->> (keys (entity-plus/lookup-kv-then-entity ent :block/properties)) (map #(:db/id (d/entity db %))))) page-ents)] (concat pages tag-pages property-pages))) diff --git a/docs/dev-practices.md b/docs/dev-practices.md index f9a33c2492..fde4492fb5 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -342,7 +342,7 @@ These tasks are specific to database graphs. For these tasks there is a one time ```sh $ bb dev:db-query woot '[:find (pull ?b [*]) :where (block-content ?b "Dogma")]' DB contains 833 datoms - [{:block/tx-id 536870923, :block/link #:db{:id 100065}, :block/uuid #uuid "65565c26-f972-4400-bce4-a15df488784d", :block/updated-at 1700158508564, :block/order "a0", :block/refs [#:db{:id 100064}], :block/created-at 1700158502056, :block/format :markdown, :block/tags [#:db{:id 100064}], :block/title "Dogma #[[65565c2a-b1c5-4dc8-a0f0-81b786bc5c6d]]", :db/id 100090, :block/parent #:db{:id 100051}, :block/page #:db{:id 100051}}] + [{:block/tx-id 536870923, :block/link #:db{:id 100065}, :block/uuid #uuid "65565c26-f972-4400-bce4-a15df488784d", :block/updated-at 1700158508564, :block/order "a0", :block/refs [#:db{:id 100064}], :block/created-at 1700158502056, :block/tags [#:db{:id 100064}], :block/title "Dogma #[[65565c2a-b1c5-4dc8-a0f0-81b786bc5c6d]]", :db/id 100090, :block/parent #:db{:id 100051}, :block/page #:db{:id 100051}}] ``` * `dev:db-transact` - Run a `d/transact!` against the queried results of a DB graph @@ -353,16 +353,18 @@ These tasks are specific to database graphs. For these tasks there is a one time Usage: $0 GRAPH-DIR QUERY TRANSACT-FN # First use the -n flag to see a dry-run of what would happen - $ bb dev:db-transact test-db '[:find ?b :where [?b :block/type "object"]]' '(fn [id] (vector :db/retract id :block/type "object"))' -n - Would update 16 blocks with the following tx: - [[:db/retract 100137 :block/type "object"] [:db/retract 100035 :block/type "object"] [:db/retract 100128 :block/type "object"] [:db/retract 100049 :block/type "object"] [:db/retract 100028 :block/type "object"] [:db/retract 100146 :block/type "object"] [:db/retract 100144 :block/type "object"] [:db/retract 100047 :block/type "object"] [:db/retract 100145 :block/type "object"] [:db/retract 100046 :block/type "object"] [:db/retract 100045 :block/type "object"] [:db/retract 100063 :block/type "object"] [:db/retract 100036 :block/type "object"] [:db/retract 100044 :block/type "object"] [:db/retract 100129 :block/type "object"] [:db/retract 100030 :block/type "object"]] + $ bb dev:db-transact test-db '[:find ?b :where [?b :block/title "say wut"]]' '(fn [id] (vector :db/add id :block/title "say woot!"))' -n + Would update 1 blocks with the following tx: + [[:db/add 169 :block/title "say woot!"]] With the following blocks updated: - ... + (#:block{:title "say wut"}) # When the transact looks good, run it without the flag - $ bb dev:db-transact test-db '[:find ?b :where [?b :block/type "object"]]' '(fn [id] (vector :db/retract id :block/type "object"))' - Updated 16 block(s) for graph test-db! + $ bb dev:db-transact test-db '[:find ?b :where [?b :block/title "say wut"]]' '(fn [id] (vector :db/add id :block/title "say woot!"))' + Updated 1 block(s) for graph test-db! ``` + + Run the dev command `Replace graph with its db.sqlite file` to use the updated graph in the desktop app. * `dev:db-create` - Create a DB graph given a `sqlite.build` EDN file @@ -410,15 +412,8 @@ These tasks are specific to database graphs. For these tasks there is a one time [[] [[162 :block/title "b7" 536871039 true] [162 :block/created-at 1703004379103 536871037 true] - [162 :block/format :markdown 536871037 true] [162 :block/page 149 536871037 true] [162 :block/parent 149 536871037 true] - [162 - :block/properties - {#uuid "21be4275-bba9-48b8-9351-c9ca27883159" - #uuid "6581b09e-8b9c-4dca-a938-c900aedc8275"} - 536871043 - true] [162 :block/refs 108 536871043 true] [162 :block/refs 160 536871043 true] [162 @@ -444,16 +439,9 @@ These tasks are specific to database graphs. For these tasks there is a one time [nil nil 536871037 536871038] [162 :block/title "b7" 536871039 true] [162 :block/created-at 1703004379103 536871037 true] - [162 :block/format :markdown 536871037 true] [162 :block/order "a0" 536871037 true] [162 :block/page 149 536871037 true] [162 :block/parent 149 536871037 true] - [162 - :block/properties - {#uuid "21be4275-bba9-48b8-9351-c9ca27883159" - #uuid "6581b09e-8b9c-4dca-a938-c900aedc8275"} - 536871043 - true] [162 :block/refs 108 536871043 true] [162 :block/refs 160 536871043 true] [162 :block/tx-id 536871043 536871044 true] diff --git a/src/main/frontend/common_keywords.cljs b/src/main/frontend/common_keywords.cljs index 1fa51264f1..b234522bec 100644 --- a/src/main/frontend/common_keywords.cljs +++ b/src/main/frontend/common_keywords.cljs @@ -5,7 +5,6 @@ (defkeywords :block/uuid {:doc "block's uuid"} :block/name {:doc "block name, lowercase, only page-blocks have this attr"} - :block/type {:doc "block type, *deprecated* in db-version"} :block/raw-title {:doc "like `:block/title`, but when eval `(:block/raw-title block-entity)`, return raw title of this block"} :kv/value {:doc "Used to store key-value, the value could be anything, diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index ca007b7a35..c894fe29d3 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -1930,8 +1930,7 @@ (or (pu/lookup block :logseq.property.pdf/hl-page) "?"))]] - (when (and area? (or (get-in block [:block/properties :hl-stamp]) - (:logseq.property.pdf/hl-image block))) + (when (and area? (:logseq.property.pdf/hl-image block)) (pdf-assets/area-display block))])] (remove-nils (concat diff --git a/src/main/frontend/db/model.cljs b/src/main/frontend/db/model.cljs index b5e88f4d03..2918410ee6 100644 --- a/src/main/frontend/db/model.cljs +++ b/src/main/frontend/db/model.cljs @@ -4,7 +4,6 @@ [clojure.walk :as walk] [datascript.core :as d] [frontend.common.graph-view :as graph-view] - [frontend.config :as config] [frontend.db.conn :as conn] [frontend.db.react :as react] [frontend.db.utils :as db-utils] @@ -80,44 +79,26 @@ independent of format as format specific heading characters are stripped" name must match the content of a page's block header" [repo page-uuid-str route-name] (let [db (conn/get-db repo)] - (if (config/db-based-graph? repo) - (->> (d/q '[:find (pull ?b [:block/uuid]) - :in $ ?page-uuid ?route-name ?content-matches % - :where - [?page :block/uuid ?page-uuid] - [?b :block/page ?page] - (has-property ?b :logseq.property/heading) - [?b :block/title ?content] - [(?content-matches ?content ?route-name ?b)]] - db - (uuid page-uuid-str) - route-name - (fn content-matches? [block-content external-content block-id] - (let [block (db-utils/entity repo block-id) - ref-tags (distinct (concat (:block/tags block) (:block/refs block)))] - (= (-> (db-content/id-ref->title-ref block-content ref-tags) - (db-content/content-id-ref->page ref-tags) - heading-content->route-name) - (string/lower-case external-content)))) - (rules/extract-rules rules/db-query-dsl-rules [:has-property])) - ffirst) - - (->> (d/q '[:find (pull ?b [:block/uuid]) - :in $ ?page-uuid ?route-name ?content-matches - :where - [?page :block/uuid ?page-uuid] - [?b :block/page ?page] - [?b :block/properties ?prop] - [(get ?prop :heading) _] - [?b :block/title ?content] - [(?content-matches ?content ?route-name)]] - db - (uuid page-uuid-str) - route-name - (fn content-matches? [block-content external-content] - (= (heading-content->route-name block-content) + (->> (d/q '[:find (pull ?b [:block/uuid]) + :in $ ?page-uuid ?route-name ?content-matches % + :where + [?page :block/uuid ?page-uuid] + [?b :block/page ?page] + (has-property ?b :logseq.property/heading) + [?b :block/title ?content] + [(?content-matches ?content ?route-name ?b)]] + db + (uuid page-uuid-str) + route-name + (fn content-matches? [block-content external-content block-id] + (let [block (db-utils/entity repo block-id) + ref-tags (distinct (concat (:block/tags block) (:block/refs block)))] + (= (-> (db-content/id-ref->title-ref block-content ref-tags) + (db-content/content-id-ref->page ref-tags) + heading-content->route-name) (string/lower-case external-content)))) - ffirst)))) + (rules/extract-rules rules/db-query-dsl-rules [:has-property])) + ffirst))) (defn get-page-format [_page-name] diff --git a/src/main/frontend/format/block.cljs b/src/main/frontend/format/block.cljs index fe196f693e..0ba9795f8e 100644 --- a/src/main/frontend/format/block.cljs +++ b/src/main/frontend/format/block.cljs @@ -1,5 +1,7 @@ (ns frontend.format.block - "Block code needed by app but not graph-parser" + "Block code needed by app but not graph-parser. This should be the only frontend + namespace that has references to legacy file attributes like :block/pre-block? + as they are being removed from graph-parser output" (:require [cljs-time.format :as tf] [cljs.cache :as cache] [clojure.string :as string] diff --git a/src/main/frontend/handler/export/common.cljs b/src/main/frontend/handler/export/common.cljs index 75123e6697..466b968600 100644 --- a/src/main/frontend/handler/export/common.cljs +++ b/src/main/frontend/handler/export/common.cljs @@ -19,7 +19,7 @@ cli-export-common/*current-db* (conn/get-db repo) cli-export-common/*content-config* (get-content-config)] (let [contents (mapv (fn [id] - (cli-export-common/get-blocks-contents repo id)) root-block-uuids)] + (cli-export-common/get-blocks-contents id)) root-block-uuids)] (string/join "\n" (mapv string/trim-newline contents))))) (defn get-page-content @@ -30,12 +30,6 @@ cli-export-common/*content-config* (get-content-config)] (cli-export-common/get-page-content page-uuid))) -;; Utils -(comment - (defn vec-tree (state/get-current-repo) blocks root-id)) ([repo blocks root-id & {:as option}] (let [db (db/get-db repo)] - (otree/blocks->vec-tree repo db blocks root-id option)))) + (otree/blocks->vec-tree db blocks root-id option)))) (def filter-top-level-blocks otree/filter-top-level-blocks) diff --git a/src/main/frontend/worker/db_worker.cljs b/src/main/frontend/worker/db_worker.cljs index 315c6d9e84..5f07babd3f 100644 --- a/src/main/frontend/worker/db_worker.cljs +++ b/src/main/frontend/worker/db_worker.cljs @@ -656,11 +656,6 @@ (when-let [conn (worker-state/get-datascript-conn repo)] (worker-export/get-debug-datoms conn))) -(def-thread-api :thread-api/export-get-all-pages - [repo] - (when-let [conn (worker-state/get-datascript-conn repo)] - (worker-export/get-all-pages repo @conn))) - (def-thread-api :thread-api/export-get-all-page->content [repo options] (when-let [conn (worker-state/get-datascript-conn repo)] diff --git a/src/main/frontend/worker/export.cljs b/src/main/frontend/worker/export.cljs index e6a60ad865..6d07bd0640 100644 --- a/src/main/frontend/worker/export.cljs +++ b/src/main/frontend/worker/export.cljs @@ -3,45 +3,7 @@ (:require [datascript.core :as d] [logseq.cli.common.file :as common-file] [logseq.common.util :as common-util] - [logseq.db :as ldb] - [logseq.graph-parser.property :as gp-property] - [logseq.outliner.tree :as otree])) - -(defn- safe-keywordize - [block] - (update block :block/properties - (fn [properties] - (when (seq properties) - (->> (filter (fn [[k _v]] - (gp-property/valid-property-name? (str k))) properties) - (into {})))))) - -(defn get-all-pages - "Get all pages and their children blocks." - [repo db] - (->> (d/q '[:find (pull ?b [*]) - :in $ - :where - [?b :block/title] - [?b :block/name]] db) - - (map (fn [[page]] - (let [whiteboard? (ldb/whiteboard? page) - blocks (ldb/get-page-blocks db (:db/id page)) - blocks' (if whiteboard? - blocks - (map (fn [b] - (let [b' (if (seq (:block/properties b)) - (update b :block/title - (fn [content] - (gp-property/remove-properties (get b :block/format :markdown) content))) - b)] - (safe-keywordize b'))) blocks)) - children (if whiteboard? - blocks' - (otree/blocks->vec-tree repo db blocks' (:db/id page))) - page' (safe-keywordize page)] - (assoc page' :block/children children)))))) + [logseq.db :as ldb])) (def get-all-page->content common-file/get-all-page->content) diff --git a/src/test/frontend/worker/rtc/client_test.cljs b/src/test/frontend/worker/rtc/client_test.cljs index 55f37695c3..98ac20d34c 100644 --- a/src/test/frontend/worker/rtc/client_test.cljs +++ b/src/test/frontend/worker/rtc/client_test.cljs @@ -15,7 +15,6 @@ :block/updated-at 1720017595873, :block/created-at 1720017595872, :db/ident :user.class/yyy, - :block/type "class", :block/name "yyy", :block/title "yyy"}])] (is (= {:move @@ -27,8 +26,7 @@ :pos [nil nil], :av-coll [[:block/name "[\"~#'\",\"yyy\"]" 1 true] - [:block/title "[\"~#'\",\"yyy\"]" 1 true] - [:block/type "[\"~#'\",\"class\"]" 1 true]]}} + [:block/title "[\"~#'\",\"yyy\"]" 1 true]]}} (:remote-ops (#'subject/local-block-ops->remote-ops db @@ -37,8 +35,7 @@ [:update 1 {:block-uuid block-uuid :av-coll [[:block/name (ldb/write-transit-str "yyy") 1 true] - [:block/title (ldb/write-transit-str "yyy") 1 true] - [:block/type (ldb/write-transit-str "class") 1 true]]}]})))))) + [:block/title (ldb/write-transit-str "yyy") 1 true]]}]})))))) (testing "user.property/xxx creation" (let [block-uuid (random-uuid) @@ -70,7 +67,6 @@ :db/cardinality :db.cardinality/one :db/ident :user.property/xxx, :block/tags [3] - :block/type "property", :block/order block-order, :block/name "xxx", :block/title "xxx"}])] @@ -84,8 +80,7 @@ :pos [nil block-order], :av-coll [[:block/name "[\"~#'\",\"xxx\"]" 1 true] - [:block/title "[\"~#'\",\"xxx\"]" 1 true] - [:block/type "[\"~#'\",\"property\"]" 1 true]]} + [:block/title "[\"~#'\",\"xxx\"]" 1 true]]} :update-schema {:block-uuid block-uuid :db/ident :user.property/xxx, @@ -102,7 +97,6 @@ [[:db/valueType (ldb/write-transit-str :db.type/ref) 1 true] [:block/name (ldb/write-transit-str "xxx") 1 true] [:block/title (ldb/write-transit-str "xxx") 1 true] - [:block/type (ldb/write-transit-str "property") 1 true] [:db/cardinality (ldb/write-transit-str :db.cardinality/one) 1 true] [:db/index (ldb/write-transit-str true) 1 true]]}]})))))) @@ -112,7 +106,6 @@ :block/updated-at 1720017595873, :block/created-at 1720017595872, :db/ident :user.class/zzz, - :block/type "class", :block/name "zzz", :block/title "zzz"}])] (is (= {:add @@ -121,13 +114,11 @@ :pos [nil nil] :av-coll [[:block/name "[\"~#'\",\"zzz\"]" 1 true] - [:block/title "[\"~#'\",\"zzz\"]" 1 true] - [:block/type "[\"~#'\",\"class\"]" 1 true]]}} + [:block/title "[\"~#'\",\"zzz\"]" 1 true]]}} (:remote-ops (#'subject/local-block-ops->remote-ops db {:add [:add 1 {:block-uuid block-uuid :av-coll [[:block/name (ldb/write-transit-str "zzz") 1 true] - [:block/title (ldb/write-transit-str "zzz") 1 true] - [:block/type (ldb/write-transit-str "class") 1 true]]}]}))))))) + [:block/title (ldb/write-transit-str "zzz") 1 true]]}]})))))))