fix: rm the last file-based namespaces in db dep

Also remove the following related file schema
attributes and their dependent code:
:block/marker, :block/priority, :block/scheduled,
:block/deadline,:block/repeated?, :block/pre-block?,
:block/properties-order, :block/properties-text-values, :block/macros,
:block/invalid-properties
This commit is contained in:
Gabriel Horner
2026-01-11 10:13:23 -05:00
parent ab137a962a
commit 4bb7430682
31 changed files with 166 additions and 371 deletions

View File

@@ -1287,12 +1287,7 @@
(= (string/lower-case (:protocol path)) "id")
(string? (:link path))
(util/uuid-string? (:link path))) ; org mode id
(let [id (uuid (:link path))
block (db/entity [:block/uuid id])]
(if (:block/pre-block? block)
(let [page (:block/page block)]
(page-reference config (:block/name page) label))
(block-reference config (:link path) label)))
(block-reference config (:link path) label)
(= protocol "file")
(if (show-link? config metadata href full_text)
@@ -1887,8 +1882,7 @@
[config block]
(let [format :markdown
block (if-not (:block.temp/ast-title block)
(merge block (block/parse-title-and-body uuid format false
(:block/title block)))
(merge block (block/parse-title-and-body uuid format (:block/title block)))
block)
block-ast-title (:block.temp/ast-title block)
config (assoc config :block block)
@@ -2168,14 +2162,13 @@
(state/set-selection-start-block! block-dom-element)))))))))))
(rum/defc dnd-separator-wrapper < rum/reactive
[block block-id top?]
[_block block-id top?]
(let [dragging? (rum/react *dragging?)
drag-to-block (rum/react *drag-to-block)
move-to (rum/react *move-to)]
(when (and
dragging?
(= block-id drag-to-block)
(not (:block/pre-block? block))
move-to)
(when-not (or (and top? (not= move-to :top))
(and (not top?) (= move-to :top)))
@@ -2402,7 +2395,7 @@
content (:block/raw-title block)
content (if (string? content) (string/trim content) "")
block-ref? (:block-ref? config)
block (merge block (block/parse-title-and-body uuid format false content))
block (merge block (block/parse-title-and-body uuid format content))
ast-body (:block.temp/ast-body block)
ast-title (:block.temp/ast-title block)
block (assoc block :block/title content)
@@ -2704,7 +2697,6 @@
(let [result (block/parse-title-and-body
uuid
(get block :block/format :markdown)
(:block/pre-block? block)
title)
ast-body (:block.temp/ast-body result)
ast-title (:block.temp/ast-title result)
@@ -2976,7 +2968,7 @@
custom-query? (boolean (:custom-query? config*))
ref-or-custom-query? (or ref? custom-query?)
*navigating-block (get container-state ::navigating-block)
{:block/keys [uuid pre-block? title]} block
{:block/keys [uuid title]} block
config (build-config config* block {:navigated? navigated? :navigating-block navigating-block})
level (:level config)
*control-show? (get container-state ::control-show?)
@@ -3045,7 +3037,6 @@
:ref #(when (nil? @*ref) (reset! *ref %))
:data-collapsed (and collapsed? has-child?)
:class (str (when selected? "selected")
(when pre-block? " pre-block")
(when order-list? " is-order-list")
(when (string/blank? title) " is-blank")
(when original-block " embed-block"))
@@ -3148,7 +3139,7 @@
;; Not embed self
[:div.flex.flex-col.w-full
(let [block (merge block (block/parse-title-and-body uuid (get block :block/format :markdown) pre-block? title))
(let [block (merge block (block/parse-title-and-body uuid (get block :block/format :markdown) title))
hide-block-refs-count? (or (and (:embed? config)
(= (:block/uuid block) (:embed-id config)))
table?)]
@@ -3460,33 +3451,6 @@
tb-col-groups
(cons head groups)))]))
(defn logbook-cp
[log]
(let [clocks (filter #(string/starts-with? % "CLOCK:") log)
clocks (reverse (sort-by str clocks))]
;; TODO: display states change log
; states (filter #(not (string/starts-with? % "CLOCK:")) log)
(when (seq clocks)
(let [tr (fn [elm cols] (->elem :tr
(mapv (fn [col] (->elem elm col)) cols)))
head [:thead.overflow-x-scroll (tr :th.py-0 ["Type" "Start" "End" "Span"])]
clock-tbody (->elem
:tbody.overflow-scroll.sm:overflow-auto
(mapv (fn [clock]
(let [cols (->> (string/split clock #": |--|=>")
(map string/trim))]
(mapv #(tr :td.py-0 %) [cols])))
clocks))]
[:div.overflow-x-scroll.sm:overflow-auto
(->elem
:table.m-0
{:class "logbook-table"
:border 0
:style {:width "max-content"}
:cell-spacing 15}
(cons head [clock-tbody]))]))))
(defn map-inline
[config col]
(map #(inline config %) col))
@@ -3588,15 +3552,7 @@
(try
(match item
["Drawer" name lines]
(when (or (not= name "logbook")
(and
(= name "logbook")
(state/enable-timetracking?)
(or (get-in (state/get-config) [:logbook/settings :enabled-in-all-blocks])
(when (get-in (state/get-config)
[:logbook/settings :enabled-in-timestamped-blocks] true)
(or (:block/scheduled (:block config))
(:block/deadline (:block config)))))))
(when (not= name "logbook")
[:div
[:div.text-sm
[:div.drawer {:data-drawer-name name}
@@ -3604,9 +3560,7 @@
[:div.opacity-50.font-medium.logbook
(util/format ":%s:" (string/upper-case name))]
[:div.opacity-50.font-medium
(if (= name "logbook")
(logbook-cp lines)
(apply str lines))
(apply str lines)
[:div ":END:"]]
{:default-collapsed? true
:title-trigger? true})]]])

View File

@@ -120,12 +120,10 @@ and handles unexpected failure."
(merge block
(parse-title-and-body (:block/uuid block)
(get block :block/format :markdown)
(:block/pre-block? block)
(:block/title block)))))
([_block-uuid format pre-block? content]
([_block-uuid format content]
(when-not (string/blank? content)
(let [content (if pre-block? content
(str (config/get-block-pattern format) " " (string/triml content)))]
(let [content (str (config/get-block-pattern format) " " (string/triml content))]
(cached-parse-title-and-body-helper format content)))))
(defn break-line-paragraph?

View File

@@ -31,7 +31,7 @@
(let [block (db/entity [:block/uuid (:block/uuid config)])
content (:block/raw-title block)
{:keys [start_pos end_pos]} (:pos_meta @(:code-options state))
offset (if (:block/pre-block? block) 0 2)
offset 2
raw-content (utf8/encode content) ;; NOTE: :pos_meta is based on byte position
prefix (utf8/decode (.slice raw-content 0 (- start_pos offset)))
surfix (utf8/decode (.slice raw-content (- end_pos offset)))

View File

@@ -52,7 +52,6 @@
[logseq.common.util.page-ref :as page-ref]
[logseq.db :as ldb]
[logseq.db.common.entity-plus :as entity-plus]
[logseq.db.file-based.schema :as file-schema]
[logseq.db.frontend.asset :as db-asset]
[logseq.db.frontend.db :as db-db]
[logseq.db.frontend.property :as db-property]
@@ -356,6 +355,10 @@
:keep-uuid? true})]
[result sibling? prev-block])))
;; This used to be a list of file attributes. Unclear if remaining ones should be removed
(def retract-attributes
#{:block/tags :block/alias :block/properties :block/warning})
(defn insert-new-block-aux!
[config
{:block/keys [uuid]
@@ -367,7 +370,7 @@
selection-end (util/get-selection-end input)
[fst-block-text snd-block-text] (compute-fst-snd-block-text value selection-start selection-end)
current-block (assoc block :block/title fst-block-text)
current-block (apply dissoc current-block file-schema/retract-attributes)
current-block (apply dissoc current-block retract-attributes)
new-m {:block/uuid (db/new-block-id)
:block/title snd-block-text}
next-block (-> (merge (select-keys block [:block/parent :block/format :block/page])
@@ -1813,7 +1816,7 @@
(if content-update-fn
(content-update-fn (:block/title block))
(:block/title block))]
(merge (apply dissoc block (conj (if-not keep-uuid? [:block/_refs] []) :block/pre-block? :block/meta))
(merge (apply dissoc block (conj (if-not keep-uuid? [:block/_refs] [])))
{:block/page {:db/id (:db/id page)}
:block/title new-content})))

View File

@@ -1,12 +1,11 @@
(ns frontend.worker.db.fix
"fix db"
(:require [datascript.core :as d]
[logseq.db :as ldb]))
[logseq.db.frontend.schema :as db-schema]))
(defn check-and-fix-schema!
[repo conn]
(let [schema (ldb/get-schema repo)
db-schema (:schema @conn)
[conn]
(let [db-schema (:schema @conn)
diffs (->> (keep (fn [[k v]]
(let [schema-v (-> (get db-schema k)
(dissoc :db/ident))
@@ -18,6 +17,6 @@
(dissoc :db/index))]
(when-not (or (= v schema-v') (= k :db/ident))
(assoc v :db/ident k))))
schema))]
db-schema/schema))]
(when (seq diffs)
(d/transact! conn diffs))))

View File

@@ -41,14 +41,15 @@
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[logseq.db.common.entity-plus :as entity-plus]
[logseq.db.common.entity-util :as common-entity-util]
[logseq.db.common.initial-data :as common-initial-data]
[logseq.db.common.order :as db-order]
[logseq.db.common.reference :as db-reference]
[logseq.db.common.sqlite :as common-sqlite]
[logseq.db.common.view :as db-view]
[logseq.db.frontend.class :as db-class]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.schema :as db-schema]
[logseq.db.sqlite.create-graph :as sqlite-create-graph]
[logseq.db.sqlite.export :as sqlite-export]
[logseq.db.sqlite.gc :as sqlite-gc]
@@ -247,9 +248,8 @@
(rtc-debug-log/create-tables! debug-log-db)
(search/create-tables-and-triggers! search-db)
(ldb/register-transact-pipeline-fn! worker-pipeline/transact-pipeline)
(let [schema (ldb/get-schema repo)
conn (common-sqlite/get-storage-conn storage schema)
_ (db-fix/check-and-fix-schema! repo conn)
(let [conn (common-sqlite/get-storage-conn storage db-schema/schema)
_ (db-fix/check-and-fix-schema! conn)
_ (when datoms
(let [eid->datoms (group-by :e datoms)
{properties true non-properties false} (group-by
@@ -695,7 +695,7 @@
[repo class-id]
(let [db @(worker-state/get-datascript-conn repo)]
(->> (db-class/get-class-objects db class-id)
(map common-entity-util/entity->map))))
(map entity-util/entity->map))))
(def-thread-api :thread-api/get-property-values
[repo {:keys [property-ident] :as option}]

View File

@@ -6,8 +6,8 @@
[frontend.worker.state :as worker-state]
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[logseq.db.common.entity-util :as common-entity-util]
[logseq.db.frontend.content :as db-content]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.schema :as db-schema]))
@@ -38,7 +38,7 @@
[db blocks page-entity graph-uuid]
(let [page-uuid (:block/uuid page-entity)
page-title (publish-entity-title page-entity)
page? (common-entity-util/page? page-entity)
page? (entity-util/page? page-entity)
graph-uuid (str graph-uuid)]
(mapcat (fn [block]
(let [block-uuid (:block/uuid block)
@@ -74,7 +74,7 @@
(defn- collect-publish-blocks
[db entity]
(if (common-entity-util/page? entity)
(if (entity-util/page? entity)
(:block/_page entity)
(ldb/get-block-and-children db (:block/uuid entity))))
@@ -209,10 +209,10 @@
eids)
(remove (fn [[_e a _v _tx _added]]
(contains? #{:block/tx-id :logseq.property.user/email :logseq.property.embedding/hnsw-label-updated-at} a))))
datoms (if (common-entity-util/page? entity)
datoms (if (entity-util/page? entity)
raw-datoms
(normalize-block-publish-datoms raw-datoms (set (map :db/id blocks)) (:db/id entity)))]
{:page (common-entity-util/entity->map entity)
{:page (entity-util/entity->map entity)
:page-uuid (:block/uuid entity)
:page-title (publish-entity-title entity)
:graph-uuid (some-> graph-uuid str)

View File

@@ -187,7 +187,7 @@
(when (or (seq remote-parents) remote-block-order) ;at least one of parent|order exists
(let [first-remote-parent (first remote-parents)
local-parent (when first-remote-parent (d/entity @conn [:block/uuid first-remote-parent]))
whiteboard-page-block? (ldb/whiteboard? local-parent)
whiteboard-page-block? (boolean (ldb/whiteboard? local-parent))
b (d/entity @conn [:block/uuid block-uuid])]
(case [whiteboard-page-block? (some? local-parent) (some? remote-block-order)]
[false true true]

View File

@@ -21,7 +21,6 @@
[goog.object :as gobj]
[logseq.api.block :as api-block]
[logseq.db :as ldb]
[logseq.db.common.entity-util :as common-entity-util]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.graph-parser.text :as text]
[logseq.outliner.core :as outliner-core]
@@ -56,7 +55,7 @@
{:keys [sibling before schema]} opts
block (if before
(db/pull (:db/id (ldb/get-left-sibling (db/entity (:db/id target))))) target)
sibling? (if (common-entity-util/page? block) false sibling)
sibling? (if (entity-util/page? block) false sibling)
uuid->properties (let [blocks (outliner-core/tree-vec-flatten blocks' :children)]
(when (some (fn [b] (seq (:properties b))) blocks)
(zipmap (map :uuid blocks)

View File

@@ -8,8 +8,8 @@
[frontend.util :as util]
[goog.object :as gobj]
[logseq.cli.common.mcp.tools :as cli-common-mcp-tools]
[logseq.db.common.entity-util :as common-entity-util]
[logseq.db.frontend.content :as db-content]))
[logseq.db.frontend.content :as db-content]
[logseq.db.frontend.entity-util :as entity-util]))
(defn- keep-json-keyword?
[k]
@@ -40,9 +40,9 @@
(gobj/get "runtime"))
cljs? (= "cljs" runtime)
input (cond
(de/entity? input) (common-entity-util/entity->map input)
(de/entity? input) (entity-util/entity->map input)
(sequential? input) (map #(if (de/entity? %)
(common-entity-util/entity->map %)
(entity-util/entity->map %)
%) input)
:else input)]
(walk/prewalk