mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 02:16:30 +00:00
Merge branch 'master' into feat/mcp-server
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
[frontend.worker.file.reset :as file-reset]
|
||||
[frontend.worker.handler.page :as worker-page]
|
||||
[frontend.worker.handler.page.file-based.rename :as file-worker-page-rename]
|
||||
[frontend.worker.pipeline :as worker-pipeline]
|
||||
[frontend.worker.rtc.asset-db-listener]
|
||||
[frontend.worker.rtc.client-op :as client-op]
|
||||
[frontend.worker.rtc.core :as rtc.core]
|
||||
@@ -41,10 +42,13 @@
|
||||
[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.schema :as db-schema]
|
||||
[logseq.db.sqlite.create-graph :as sqlite-create-graph]
|
||||
[logseq.db.sqlite.export :as sqlite-export]
|
||||
@@ -253,8 +257,8 @@
|
||||
(doseq [db (if @*publishing? [sqlite-db] [sqlite-db client-ops-db])]
|
||||
(sqlite-gc/gc-kvs-table! db {:full-gc? full-gc?})
|
||||
(.exec db "VACUUM"))
|
||||
(d/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at
|
||||
:kv/value (common-util/time-ms)}]))))
|
||||
(ldb/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at
|
||||
:kv/value (common-util/time-ms)}]))))
|
||||
|
||||
(defn- create-or-open-db!
|
||||
[repo {:keys [config datoms] :as opts}]
|
||||
@@ -272,6 +276,9 @@
|
||||
(common-sqlite/create-kvs-table! db)
|
||||
(when-not @*publishing? (common-sqlite/create-kvs-table! client-ops-db))
|
||||
(search/create-tables-and-triggers! search-db)
|
||||
(ldb/register-transact-pipeline-fn!
|
||||
(fn [tx-report]
|
||||
(worker-pipeline/transact-pipeline repo tx-report)))
|
||||
(let [schema (ldb/get-schema repo)
|
||||
conn (common-sqlite/get-storage-conn storage schema)
|
||||
_ (db-fix/check-and-fix-schema! repo conn)
|
||||
@@ -293,7 +300,7 @@
|
||||
(let [config (or config "")
|
||||
initial-data (sqlite-create-graph/build-db-initial-data
|
||||
config (select-keys opts [:import-type :graph-git-sha]))]
|
||||
(d/transact! conn initial-data {:initial-db? true})))
|
||||
(ldb/transact! conn initial-data {:initial-db? true})))
|
||||
|
||||
(gc-sqlite-dbs! db client-ops-db conn {})
|
||||
|
||||
@@ -462,7 +469,9 @@
|
||||
(def-thread-api :thread-api/get-block-refs
|
||||
[repo id]
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(ldb/get-block-refs @conn id)))
|
||||
(->> (db-reference/get-linked-references @conn id)
|
||||
:ref-blocks
|
||||
(map (fn [b] (assoc (into {} b) :db/id (:db/id b)))))))
|
||||
|
||||
(def-thread-api :thread-api/get-block-refs-count
|
||||
[repo id]
|
||||
@@ -628,7 +637,9 @@
|
||||
{:keys [type payload]} (when (map? data) data)]
|
||||
(case type
|
||||
:notification
|
||||
(shared-service/broadcast-to-clients! :notification [(:message payload) (:type payload)])
|
||||
(do
|
||||
(log/error ::apply-outliner-ops-failed e)
|
||||
(shared-service/broadcast-to-clients! :notification [(:message payload) (:type payload)]))
|
||||
(throw e)))))))
|
||||
|
||||
(def-thread-api :thread-api/file-writes-finished?
|
||||
@@ -698,6 +709,12 @@
|
||||
(let [db @(worker-state/get-datascript-conn repo)]
|
||||
(db-view/get-view-data db view-id option)))
|
||||
|
||||
(def-thread-api :thread-api/get-class-objects
|
||||
[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))))
|
||||
|
||||
(def-thread-api :thread-api/get-property-values
|
||||
[repo {:keys [property-ident] :as option}]
|
||||
(let [conn (worker-state/get-datascript-conn repo)]
|
||||
@@ -896,9 +913,19 @@
|
||||
(reset! *service [graph service])
|
||||
service)))))
|
||||
|
||||
(defn- notify-invalid-data
|
||||
[{:keys [tx-meta]}]
|
||||
;; don't notify on production when undo/redo failed
|
||||
(when-not (and (or (:undo? tx-meta) (:redo? tx-meta))
|
||||
(not worker-util/dev?))
|
||||
(shared-service/broadcast-to-clients! :notification
|
||||
[["Invalid DB!"] :error])))
|
||||
|
||||
(defn init
|
||||
"web worker entry"
|
||||
[]
|
||||
(ldb/register-transact-invalid-callback-fn! notify-invalid-data)
|
||||
|
||||
(let [proxy-object (->>
|
||||
fns
|
||||
(map
|
||||
|
||||
Reference in New Issue
Block a user