Bläddra i källkod

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
Gabriel Horner 1 vecka sedan
förälder
incheckning
0936e0c4b1

+ 3 - 3
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?

+ 1 - 1
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)))

+ 1 - 2
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

+ 0 - 1
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

+ 1 - 3
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 '$ '%])

+ 12 - 25
deps/db/src/logseq/db.cljs

@@ -420,7 +420,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' "/")
@@ -619,30 +618,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]

+ 8 - 10
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)))

+ 1 - 2
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}))

+ 10 - 16
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?

+ 1 - 1
deps/outliner/src/logseq/outliner/property.cljs

@@ -700,7 +700,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))))
 

+ 4 - 4
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

+ 2 - 1
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)))

+ 9 - 21
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]

+ 0 - 1
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,

+ 1 - 2
src/main/frontend/components/block.cljs

@@ -1928,8 +1928,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

+ 19 - 38
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]

+ 3 - 1
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]

+ 1 - 7
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 <get-all-pages
-    [repo]
-    (state/<invoke-db-worker :thread-api/export-get-all-pages repo)))
-
 (defn <get-debug-datoms
   [repo]
   (state/<invoke-db-worker :thread-api/export-get-debug-datoms repo))

+ 6 - 9
src/main/frontend/handler/property/util.cljs

@@ -6,18 +6,15 @@
             [frontend.state :as state]
             [logseq.db.common.property-util :as db-property-util]))
 
-(defn lookup
-  "Get the property value by a built-in property's db-ident from block. For file and db graphs"
-  [block key]
-  (let [repo (state/get-current-repo)]
-    (db-property-util/lookup repo block key)))
+(def lookup
+  "Get the property value by a built-in property's db-ident from block."
+  db-property-util/lookup)
 
 (defn get-block-property-value
   "Get the value of a built-in block's property by its db-ident"
   [block db-ident]
-  (let [repo (state/get-current-repo)
-        db (conn/get-db repo)]
-    (db-property-util/get-block-property-value repo db block db-ident)))
+  (let [db (conn/get-db (state/get-current-repo))]
+    (db-property-util/get-block-property-value db block db-ident)))
 
 (defn get-pid
   "Get a built-in property's id (db-ident or name) given its db-ident. For file and db graphs"
@@ -29,4 +26,4 @@
   [block]
   (let [repo (state/get-current-repo)
         db (conn/get-db repo)]
-    (db-property-util/shape-block? repo db block)))
+    (db-property-util/shape-block? db block)))

+ 1 - 1
src/main/frontend/modules/outliner/tree.cljs

@@ -9,7 +9,7 @@
    (blocks->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)
 

+ 0 - 5
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)]

+ 1 - 39
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)
 

+ 5 - 14
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]]}]})))))))