From b264d17309b079cb59a945b38166fd3d8661d8ac Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Tue, 5 Sep 2023 17:02:30 -0400 Subject: [PATCH] Move db-graph property fns to its own logseq.db ns db-graph related fns like these shouldn't be in the graph-parser dep as that dep should only really be used with file graphs as much as possible. This is also being done in preparation for making the create-graph ns independent of the frontend Also db- prefixes in fns were dropped since the ns now carries the db- prefix --- .clj-kondo/config.edn | 6 +- deps/db/.carve/config.edn | 1 + deps/db/src/logseq/db/property.cljs | 85 +++++++++++++++++ .../src/logseq/graph_parser/property.cljs | 94 +------------------ src/main/frontend/components/content.cljs | 4 +- src/main/frontend/components/page.cljs | 6 +- src/main/frontend/components/page_menu.cljs | 4 +- src/main/frontend/components/property.cljs | 19 ++-- src/main/frontend/components/query_table.cljs | 4 +- src/main/frontend/db/restore.cljs | 4 +- src/main/frontend/handler/common/repo.cljs | 4 +- src/main/frontend/handler/editor.cljs | 4 +- src/main/frontend/handler/page.cljs | 3 +- src/main/frontend/handler/property.cljs | 28 +++--- src/main/frontend/handler/property/util.cljs | 6 +- src/main/frontend/search.cljs | 4 +- 16 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 deps/db/src/logseq/db/property.cljs diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 8c2527146f..5e5707a7d0 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -77,7 +77,7 @@ frontend.handler.ui ui-handler frontend.handler.notification notification frontend.handler.page page-handler - frontend.handler.db-based.property db-property + frontend.handler.db-based.property db-property-handler frontend.handler.file-based.property file-property frontend.handler.file-based.property.util property-util frontend.handler.plugin plugin-handler @@ -111,7 +111,11 @@ logseq.common.path path logseq.common.graph common-graph logseq.common.config common-config + logseq.db.property db-property + logseq.db.rules rules + logseq.db.schema db-schema logseq.db.sqlite.db sqlite-db + logseq.db.sqlite.util sqlite-util logseq.graph-parser graph-parser logseq.graph-parser.text text logseq.graph-parser.block gp-block diff --git a/deps/db/.carve/config.edn b/deps/db/.carve/config.edn index ffbc4c2e0f..8faeb33903 100644 --- a/deps/db/.carve/config.edn +++ b/deps/db/.carve/config.edn @@ -4,6 +4,7 @@ logseq.db.sqlite.rtc logseq.db.sqlite.util logseq.db.sqlite.cli + logseq.db.property ;; Some fns are used by frontend but not worth moving over yet logseq.db.schema] :report {:format :ignore}} diff --git a/deps/db/src/logseq/db/property.cljs b/deps/db/src/logseq/db/property.cljs new file mode 100644 index 0000000000..00687c43e2 --- /dev/null +++ b/deps/db/src/logseq/db/property.cljs @@ -0,0 +1,85 @@ +(ns logseq.db.property + "Property related fns for DB graphs and frontend/datascript usage" + (:require [clojure.set :as set])) + +;; FIXME: no support for built-in-extended-properties +(def ^:large-vars/data-var built-in-properties + "Map of built in properties for db graphs. Each property has a config map with + the following keys: + * :schema - Property's schema. Required key + * :original-name - Property's :block/original-name + * :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties + * :visible - Boolean to indicate user can see and use this property" + {:alias {:original-name "Alias" + :attribute :block/alias + :visible true + :schema {:type :page + :cardinality :many}} + :tags {:original-name "Tags" + :attribute :block/tags + :visible true + :schema {:type :page + :cardinality :many}} + :background-color {:schema {:type :default}} + :heading {:schema {:type :any}} ; number (1-6) or boolean for auto heading + :query-table {:schema {:type :checkbox}} + ;; query-properties is a coll of property uuids and keywords where keywords are special frontend keywords + :query-properties {:schema {:type :coll}} + ;; query-sort-by is either a property uuid or a keyword where keyword is a special frontend keyword + :query-sort-by {:schema {:type :any}} + :query-sort-desc {:schema {:type :checkbox}} + :logseq.query/nlp-date {:schema {:type :checkbox}} + :ls-type {:schema {:type :keyword}} + :hl-type {:schema {:type :keyword}} + :hl-page {:schema {:type :number}} + :hl-stamp {:schema {:type :number}} + :hl-color {:schema {:type :default}} + :logseq.macro-name {:schema {:type :default}} + :logseq.macro-arguments {:schema {:type :default}} + :logseq.order-list-type {:schema {:type :checkbox}} + :logseq.tldraw.page {:schema {:type :map}} + :logseq.tldraw.shape {:schema {:type :map}} + ;; color props + :logseq.color {:schema {:type :default} + :visible true} + ;; table-v2 props + :logseq.table.version {:schema {:type :number} + :visible true} + :logseq.table.compact {:schema {:type :checkbox} + :visible true} + :logseq.table.headers {:schema {:type :default} + :visible true} + :logseq.table.hover {:schema {:type :default} + :visible true} + :logseq.table.borders {:schema {:type :checkbox} + :visible true} + :logseq.table.stripes {:schema {:type :checkbox} + :visible true} + :logseq.table.max-width {:schema {:type :number} + :visible true} + + :icon {:original-name "Icon" + :schema {:type :map}} + :public {:schema {:type :checkbox}} + :filters {:schema {:type :map}} + :exclude-from-graph-view {:schema {:type :checkbox}} + :created-in-property {:schema {:type :checkbox}}}) + +(def visible-built-in-properties + "These are built-in properties that users can see and use" + (set (keep (fn [[k v]] (when (:visible v) k)) built-in-properties))) + +(defonce built-in-properties-keys + (set (keys built-in-properties))) + +(def hidden-built-in-properties + (set/difference built-in-properties-keys visible-built-in-properties)) + +(defonce built-in-properties-keys-str + (set (map name (keys built-in-properties)))) + +(defn valid-property-name? + [s] + {:pre [(string? s)]} + ;; Disallow tags or page refs as they would create unreferenceable page names + (not (re-find #"^(#|\[\[)" s))) \ No newline at end of file diff --git a/deps/graph-parser/src/logseq/graph_parser/property.cljs b/deps/graph-parser/src/logseq/graph_parser/property.cljs index 40f62251b5..9fdb1fde7b 100644 --- a/deps/graph-parser/src/logseq/graph_parser/property.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/property.cljs @@ -1,13 +1,11 @@ (ns logseq.graph-parser.property - "Core vars and util fns for properties" + "Core vars and util fns for properties and file based graphs" (:require [logseq.graph-parser.util :as gp-util] [clojure.string :as string] [clojure.set :as set] [goog.string :as gstring] [goog.string.format])) -;; Graph agnostic fns -;; ================== (def colons "Property delimiter for markdown mode" "::") (defn colons-org "Property delimiter for org mode" @@ -28,9 +26,6 @@ (contains? #{"Property_Drawer" "Properties"} (first block)))) -;; Configuration and fns for older, file graph properties -;; ============= - (defn valid-property-name? [s] {:pre [(string? s)]} @@ -162,89 +157,4 @@ lines (concat before middle after)] (string/join "\n" lines)) content)) - content)) - -;; Configuration and fns for db graph properties -;; ============= - -;; FIXME: no support for built-in-extended-properties -(def db-built-in-properties - "Map of built in properties for db graphs. Each property has a config map with - the following keys: - * :schema - Property's schema. Required key - * :original-name - Property's :block/original-name - * :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties - * :visible - Boolean to indicate user can see and use this property" - {:alias {:original-name "Alias" - :attribute :block/alias - :visible true - :schema {:type :page - :cardinality :many}} - :tags {:original-name "Tags" - :attribute :block/tags - :visible true - :schema {:type :page - :cardinality :many}} - :background-color {:schema {:type :default}} - :heading {:schema {:type :any}} ; number (1-6) or boolean for auto heading - :query-table {:schema {:type :checkbox}} - ;; query-properties is a coll of property uuids and keywords where keywords are special frontend keywords - :query-properties {:schema {:type :coll}} - ;; query-sort-by is either a property uuid or a keyword where keyword is a special frontend keyword - :query-sort-by {:schema {:type :any}} - :query-sort-desc {:schema {:type :checkbox}} - :logseq.query/nlp-date {:schema {:type :checkbox}} - :ls-type {:schema {:type :keyword}} - :hl-type {:schema {:type :keyword}} - :hl-page {:schema {:type :number}} - :hl-stamp {:schema {:type :number}} - :hl-color {:schema {:type :default}} - :logseq.macro-name {:schema {:type :default}} - :logseq.macro-arguments {:schema {:type :default}} - :logseq.order-list-type {:schema {:type :checkbox}} - :logseq.tldraw.page {:schema {:type :map}} - :logseq.tldraw.shape {:schema {:type :map}} - ;; color props - :logseq.color {:schema {:type :default} - :visible true} - ;; table-v2 props - :logseq.table.version {:schema {:type :number} - :visible true} - :logseq.table.compact {:schema {:type :checkbox} - :visible true} - :logseq.table.headers {:schema {:type :default} - :visible true} - :logseq.table.hover {:schema {:type :default} - :visible true} - :logseq.table.borders {:schema {:type :checkbox} - :visible true} - :logseq.table.stripes {:schema {:type :checkbox} - :visible true} - :logseq.table.max-width {:schema {:type :number} - :visible true} - - :icon {:original-name "Icon" - :schema {:type :map}} - :public {:schema {:type :checkbox}} - :filters {:schema {:type :map}} - :exclude-from-graph-view {:schema {:type :checkbox}} - :created-in-property {:schema {:type :checkbox}}}) - -(def db-visible-built-in-properties - "These are built-in properties that users can see and use" - (set (keep (fn [[k v]] (when (:visible v) k)) db-built-in-properties))) - -(defonce db-built-in-properties-keys - (set (keys db-built-in-properties))) - -(def db-hidden-built-in-properties - (set/difference db-built-in-properties-keys db-visible-built-in-properties)) - -(defonce db-built-in-properties-keys-str - (set (map name (keys db-built-in-properties)))) - -(defn db-valid-property-name? - [s] - {:pre [(string? s)]} - ;; Disallow tags or page refs as they would create unreferenceable page names - (not (re-find #"^(#|\[\[)" s))) + content)) \ No newline at end of file diff --git a/src/main/frontend/components/content.cljs b/src/main/frontend/components/content.cljs index c413f0addd..f7c08ff3eb 100644 --- a/src/main/frontend/components/content.cljs +++ b/src/main/frontend/components/content.cljs @@ -28,7 +28,7 @@ [goog.dom :as gdom] [goog.object :as gobj] [rum.core :as rum] - [logseq.graph-parser.property :as gp-property] + [logseq.db.property :as db-property] [frontend.config :as config])) ;; TODO i18n support @@ -349,7 +349,7 @@ (rum/defc property-custom-context-menu-content [block property {:keys [class-schema?]}] (let [repo (state/get-current-repo) - built-in-property? (contains? gp-property/db-built-in-properties-keys-str (:block/name property))] + built-in-property? (contains? db-property/built-in-properties-keys-str (:block/name property))] [:.menu-links-wrapper (when-not built-in-property? (ui/menu-link diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 456c6f5fe2..b2021a208d 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -42,7 +42,7 @@ [logseq.graph-parser.util.page-ref :as page-ref] [logseq.graph-parser.mldoc :as gp-mldoc] [frontend.handler.property.util :as pu] - [logseq.graph-parser.property :as gp-property])) + [logseq.db.property :as db-property])) (defn- get-page-name [state] @@ -331,7 +331,7 @@ (not fmt-journal?) (not config/publishing?) (not (and (= "property" (:block/type page)) - (contains? gp-property/db-built-in-properties-keys-str page-name)))) + (contains? db-property/built-in-properties-keys-str page-name)))) (reset! *input-value (if untitled? "" old-name)) (reset! *edit? true)))))} (when (not= icon "") [:span.page-icon icon]) @@ -505,7 +505,7 @@ journal? (db/journal-page? page-name) db-based? (config/db-based-graph? repo) built-in-property? (and (= "property" (:block/type page)) - (contains? gp-property/db-built-in-properties-keys-str page-name)) + (contains? db-property/built-in-properties-keys-str page-name)) fmt-journal? (boolean (date/journal-title->int page-name)) whiteboard? (:whiteboard? option) ;; in a whiteboard portal shape? whiteboard-page? (model/whiteboard-page? page-name) ;; is this page a whiteboard? diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index 8cacbc7268..52974eba12 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/src/main/frontend/components/page_menu.cljs @@ -19,7 +19,7 @@ [frontend.handler.file-sync :as file-sync-handler] [logseq.common.path :as path] [frontend.handler.property.util :as pu] - [logseq.graph-parser.property :as gp-property])) + [logseq.db.property :as db-property])) (defn- delete-page! [page-name] @@ -81,7 +81,7 @@ (file-sync-handler/enable-sync?) (file-sync-handler/get-current-graph-uuid)) built-in-property? (and (= "property" (:block/type page)) - (contains? gp-property/db-built-in-properties-keys-str page-name))] + (contains? db-property/built-in-properties-keys-str page-name))] (when (and page (not block?)) (->> [(when-not config/publishing? diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index d42035dcb6..8a7cdb894e 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -8,7 +8,7 @@ [frontend.db :as db] [frontend.db-mixins :as db-mixins] [frontend.db.model :as db-model] - [frontend.handler.db-based.property :as db-property] + [frontend.handler.db-based.property :as db-property-handler] [frontend.handler.notification :as notification] [frontend.handler.property :as property-handler] [frontend.handler.property.util :as pu] @@ -18,8 +18,7 @@ [frontend.state :as state] [frontend.ui :as ui] [frontend.util :as util] - [logseq.graph-parser.property :as gp-property] - [reitit.frontend.easy :as rfe] + [logseq.db.property :as db-property] [rum.core :as rum])) (rum/defc icon @@ -91,7 +90,7 @@ [state repo property {:keys [toggle-fn block] :as opts}] (let [*property-name (::property-name state) *property-schema (::property-schema state) - built-in-property? (contains? gp-property/db-built-in-properties-keys-str (:block/original-name property)) + built-in-property? (contains? db-property/built-in-properties-keys-str (:block/original-name property)) property (db/sub-block (:db/id property))] [:div.property-configure.flex.flex-1.flex-col [:div.font-bold.text-xl @@ -189,7 +188,7 @@ (let [repo (state/get-current-repo)] ;; existing property selected or entered (if-let [property (get-property-from-db property-name)] - (if (contains? gp-property/db-hidden-built-in-properties (keyword property-name)) + (if (contains? db-property/hidden-built-in-properties (keyword property-name)) (do (notification/show! "This is a built-in property that can't be used." :error) (pv/exit-edit-property)) (if (= "class" (:block/type entity)) @@ -200,11 +199,11 @@ (let [editor-id (str "ls-property-" blocks-container-id (:db/id entity) "-" (:db/id property))] (pv/set-editing! property editor-id "" "")))) ;; new property entered - (if (gp-property/db-valid-property-name? property-name) + (if (db-property/valid-property-name? property-name) (if (= "class" (:block/type entity)) (pv/add-property! entity property-name "" {:class-schema? class-schema? :exit-edit? page-configure?}) (do - (db-property/upsert-property! repo property-name {:type :default} {}) + (db-property-handler/upsert-property! repo property-name {:type :default} {}) (when *show-new-property-config? (reset! *show-new-property-config? true)))) (do (notification/show! "This is an invalid property name. A property name cannot start with page reference characters '#' or '[['." :error) @@ -221,8 +220,8 @@ (map #(:block/original-name (db/entity [:block/uuid %]))) (set)) existing-tag-alias (reduce (fn [acc prop] - (if (seq (get entity (get-in gp-property/db-built-in-properties [prop :attribute]))) - (conj acc (get-in gp-property/db-built-in-properties [prop :original-name])) + (if (seq (get entity (get-in db-property/built-in-properties [prop :attribute]))) + (conj acc (get-in db-property/built-in-properties [prop :original-name])) acc)) #{} [:tags :alias]) @@ -428,7 +427,7 @@ (remove (fn [x] (let [id (if (uuid? x) x (first x))] (when (uuid? id) - (contains? gp-property/db-hidden-built-in-properties (keyword (:block/name (db/entity [:block/uuid id]))))))) + (contains? db-property/hidden-built-in-properties (keyword (:block/name (db/entity [:block/uuid id]))))))) properties)) classes (->> (:block/tags block) (sort-by :block/name) diff --git a/src/main/frontend/components/query_table.cljs b/src/main/frontend/components/query_table.cljs index 68974bec88..505a01cac3 100644 --- a/src/main/frontend/components/query_table.cljs +++ b/src/main/frontend/components/query_table.cljs @@ -17,7 +17,7 @@ [medley.core :as medley] [rum.core :as rum] [logseq.graph-parser.text :as text] - [logseq.graph-parser.property :as gp-property] + [logseq.db.property :as db-property] [frontend.handler.property.util :as pu])) ;; Util fns @@ -108,7 +108,7 @@ ;; TODO: Support additional hidden properties e.g. from user config ;; or gp-property/built-in-extended properties (set (map #(:block/uuid (db/entity repo [:block/name %])) - gp-property/db-built-in-properties-keys-str)) + db-property/built-in-properties-keys-str)) (conj (file-property/built-in-properties) :template)) prop-keys* (->> (distinct (mapcat keys (map :block/properties result))) (remove hidden-properties)) diff --git a/src/main/frontend/db/restore.cljs b/src/main/frontend/db/restore.cljs index c777a2d8ab..a099c0ffeb 100644 --- a/src/main/frontend/db/restore.cljs +++ b/src/main/frontend/db/restore.cljs @@ -18,7 +18,7 @@ [promesa.core :as p] [frontend.util :as util] [cljs-time.core :as t] - [logseq.graph-parser.property :as gp-property])) + [logseq.db.property :as db-property])) (defn- old-schema? "Requires migration if the schema version is older than db-schema/version" @@ -87,7 +87,7 @@ :block/name (util/page-name-sanity-lc k-name) :block/uuid (db/new-block-id) :block/type "property"}))))) - gp-property/db-built-in-properties)] + db-property/built-in-properties)] (when (seq txs) (d/transact! conn txs)))) diff --git a/src/main/frontend/handler/common/repo.cljs b/src/main/frontend/handler/common/repo.cljs index 9f8690f0ed..040764845c 100644 --- a/src/main/frontend/handler/common/repo.cljs +++ b/src/main/frontend/handler/common/repo.cljs @@ -1,6 +1,6 @@ (ns ^:nbb-compatible frontend.handler.common.repo (:require [datascript.core :as d] - [logseq.graph-parser.property :as gp-property] + [logseq.db.property :as db-property] [logseq.graph-parser.util :as gp-util] [logseq.db.sqlite.util :as sqlite-util])) @@ -24,5 +24,5 @@ :block/name (gp-util/page-name-sanity-lc k-name) :block/uuid (d/squuid) :block/type "property"}))) - gp-property/db-built-in-properties)] + db-property/built-in-properties)] (concat initial-files default-properties))) \ No newline at end of file diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index da754ec644..d719640100 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -60,7 +60,7 @@ [logseq.graph-parser.util.page-ref :as page-ref] [promesa.core :as p] [rum.core :as rum] - [frontend.handler.db-based.property :as db-property])) + [frontend.handler.db-based.property :as db-property-handler])) ;; FIXME: should support multiple images concurrently uploading @@ -510,7 +510,7 @@ (wrap-parse-block) (assoc :block/uuid (or custom-uuid (db/new-block-id)))) new-block (if (and db-based? (seq properties)) - (assoc new-block :block/properties (db-property/replace-key-with-id! properties)) + (assoc new-block :block/properties (db-property-handler/replace-key-with-id! properties)) new-block) new-block (merge new-block other-attrs) [block-m sibling?] (cond diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 27939a2391..a41a7cf814 100644 --- a/src/main/frontend/handler/page.cljs +++ b/src/main/frontend/handler/page.cljs @@ -38,6 +38,7 @@ [goog.object :as gobj] [lambdaisland.glogi :as log] [logseq.db.schema :as db-schema] + [logseq.db.property :as db-property] [logseq.graph-parser.block :as gp-block] [logseq.graph-parser.config :as gp-config] [logseq.graph-parser.property :as gp-property] @@ -966,7 +967,7 @@ (or (util/uuid-string? name) (gp-config/draw? name) (db/built-in-pages-names (string/upper-case name)) - (gp-property/db-built-in-properties-keys-str name) + (db-property/built-in-properties-keys-str name) (contains? #{"macro"} (:block/type p)))))) (common-handler/fix-pages-timestamps))) diff --git a/src/main/frontend/handler/property.cljs b/src/main/frontend/handler/property.cljs index f5a8cfdd51..620b703d5b 100644 --- a/src/main/frontend/handler/property.cljs +++ b/src/main/frontend/handler/property.cljs @@ -1,39 +1,39 @@ (ns frontend.handler.property "Block properties handler." - (:require [frontend.handler.db-based.property :as db-property] + (:require [frontend.handler.db-based.property :as db-property-handler] [frontend.handler.file-based.property :as file-property] [frontend.config :as config] [frontend.state :as state] [frontend.db :as db])) -(def user-face-builtin-schema-types db-property/user-face-builtin-schema-types) -(def internal-builtin-schema-types db-property/internal-builtin-schema-types) +(def user-face-builtin-schema-types db-property-handler/user-face-builtin-schema-types) +(def internal-builtin-schema-types db-property-handler/internal-builtin-schema-types) (defn remove-block-property! [repo block-id key] (if (config/db-based-graph? repo) - (db-property/remove-block-property! repo block-id key) + (db-property-handler/remove-block-property! repo block-id key) (file-property/remove-block-property! block-id key))) (defn set-block-property! [repo block-id key v & opts] (if (config/db-based-graph? repo) (if (nil? v) - (db-property/remove-block-property! repo block-id key) - (db-property/set-block-property! repo block-id key v opts)) + (db-property-handler/remove-block-property! repo block-id key) + (db-property-handler/set-block-property! repo block-id key v opts)) (file-property/set-block-property! block-id key v))) (defn update-property! [repo property-uuid opts] {:pre [(uuid? property-uuid)]} (when (config/db-based-graph? repo) - (db-property/update-property! repo property-uuid opts))) + (db-property-handler/update-property! repo property-uuid opts))) (defn delete-property-value! "Delete value if a property has multiple values" [repo block property-id property-value] (when (config/db-based-graph? repo) - (db-property/delete-property-value! repo block property-id property-value))) + (db-property-handler/delete-property-value! repo block property-id property-value))) (defn set-editing-new-property! [value] @@ -48,13 +48,13 @@ [repo class-uuid k-name] (when-let [class (db/entity repo [:block/uuid class-uuid])] (when (config/db-based-graph? repo) - (db-property/class-add-property! repo class k-name)))) + (db-property-handler/class-add-property! repo class k-name)))) (defn class-remove-property! [repo class-uuid k-uuid] (when-let [class (db/entity repo [:block/uuid class-uuid])] (when (config/db-based-graph? repo) - (db-property/class-remove-property! repo class k-uuid)))) + (db-property-handler/class-remove-property! repo class k-uuid)))) (defn remove-id-property [repo format content] @@ -70,15 +70,15 @@ (defn batch-remove-block-property! [repo block-ids key] (if (config/db-based-graph? repo) - (db-property/batch-remove-property! repo block-ids key) + (db-property-handler/batch-remove-property! repo block-ids key) (file-property/batch-remove-block-property! block-ids key))) (defn batch-set-block-property! [repo block-ids key value] (if (config/db-based-graph? repo) (if (nil? value) - (db-property/batch-remove-property! repo block-ids key) - (db-property/batch-set-property! repo block-ids key value)) + (db-property-handler/batch-remove-property! repo block-ids key) + (db-property-handler/batch-set-property! repo block-ids key value)) (file-property/batch-set-block-property! block-ids key value))) (defn file-batch-set-property! @@ -89,5 +89,5 @@ (defn replace-key-with-id! [repo m] (if (config/db-based-graph? repo) - (db-property/replace-key-with-id! m) + (db-property-handler/replace-key-with-id! m) m)) diff --git a/src/main/frontend/handler/property/util.cljs b/src/main/frontend/handler/property/util.cljs index 94b4f3ce3a..b44d9947a0 100644 --- a/src/main/frontend/handler/property/util.cljs +++ b/src/main/frontend/handler/property/util.cljs @@ -1,7 +1,7 @@ (ns frontend.handler.property.util (:require [frontend.config :as config] [frontend.state :as state] - [logseq.graph-parser.property :as gp-property] + [logseq.db.property :as db-property] [logseq.graph-parser.util :as gp-util] [frontend.db :as db] [clojure.set :as set])) @@ -12,7 +12,7 @@ (let [repo (state/get-current-repo)] (if (and (config/db-based-graph? repo) (keyword? key) - (contains? gp-property/db-built-in-properties-keys key)) + (contains? db-property/built-in-properties-keys key)) (when-let [property (db/entity repo [:block/name (gp-util/page-name-sanity-lc (name key))])] (get coll (:block/uuid property))) (get coll key)))) @@ -47,6 +47,6 @@ (let [built-in-properties (set (map (fn [p] (:block/uuid (db/entity [:block/name (name p)]))) - gp-property/db-built-in-properties-keys))] + db-property/built-in-properties-keys))] (swap! *db-built-in-properties assoc repo built-in-properties))) (set/subset? (set properties) (get @*db-built-in-properties repo)))) diff --git a/src/main/frontend/search.cljs b/src/main/frontend/search.cljs index 34b32154de..93b63f7a2d 100644 --- a/src/main/frontend/search.cljs +++ b/src/main/frontend/search.cljs @@ -18,7 +18,7 @@ [datascript.core :as d] [frontend.handler.file-based.property.util :as property-util] [frontend.config :as config] - [logseq.graph-parser.property :as gp-property])) + [logseq.db.property :as db-property])) (defn get-engine [repo] @@ -186,7 +186,7 @@ (defn get-all-properties [] (let [hidden-props (if (config/db-based-graph? (state/get-current-repo)) - (set (map name gp-property/db-hidden-built-in-properties)) + (set (map name db-property/hidden-built-in-properties)) (set (map name (property-util/hidden-properties))))] (remove hidden-props (db-model/get-all-properties))))