Browse Source

Replace more :block/type

Tienson Qin 1 year ago
parent
commit
c5fa699db0

+ 2 - 2
deps/db/src/logseq/db.cljs

@@ -536,7 +536,7 @@
 
 (defn get-all-properties
   [db]
-  (->> (d/datoms db :avet :block/type "property")
+  (->> (d/datoms db :avet :block/tags :logseq.class/Property)
        (map (fn [d]
               (d/entity db (:e d))))))
 
@@ -555,7 +555,7 @@
 
 (defn get-title-with-parents
   [entity]
-  (if (contains? #{"page" "class"} (:block/type entity))
+  (if (or (entity-util/class? entity) (entity-util/internal-page? entity))
     (let [parents' (->> (get-page-parents entity)
                         (remove (fn [e] (= :logseq.class/Root (:db/ident e))))
                         vec)]

+ 2 - 2
deps/db/src/logseq/db/frontend/entity_plus.cljc

@@ -27,7 +27,7 @@
   [^Entity e k default-value]
   (let [db (.-db e)
         db-based? (db-based-graph? db)]
-    (if (and db-based? (= "journal" (:block/type e)))
+    (if (and db-based? (entity-util/journal? e))
       (get-journal-title db e)
       (let [search? (get (.-kv e) :block.temp/search?)]
         (or
@@ -65,7 +65,7 @@
        (let [db (.-db e)]
          (case k
            :block/raw-title
-           (if (and (db-based-graph? db) (= "journal" (:block/type e)))
+           (if (and (db-based-graph? db) (entity-util/journal? e))
              (get-journal-title db e)
              (lookup-entity e :block/title default-value))
 

+ 4 - 2
deps/db/src/logseq/db/frontend/entity_util.cljs

@@ -12,8 +12,10 @@
 
 (defn- has-tag?
   [entity tag-ident]
-  (some (fn [t] (or (= (:db/ident t) tag-ident)
-                    (= t tag-ident))) (:block/tags entity)))
+  (let [tags (:block/tags entity)]
+    (some (fn [t] (or (= (:db/ident t) tag-ident)
+                      (= t tag-ident)))
+          (if (coll? tags) tags [tags]))))
 
 (defn internal-page?
   [entity]

+ 17 - 7
deps/db/src/logseq/db/frontend/rules.cljc

@@ -155,8 +155,18 @@
    (dissoc query-dsl-rules :namespace
            :page-property :has-page-property
            :page-tags :all-page-tags)
+
    (dissoc rules :namespace)
-   {:existing-property-value
+
+   {:between
+    '[(between ?b ?start ?end)
+      [?b :block/page ?p]
+      [?p :block/tags :logseq.class/Journal]
+      [?p :block/journal-day ?d]
+      [(>= ?d ?start)]
+      [(<= ?d ?end)]]
+
+    :existing-property-value
     '[;; non-ref value
       [(existing-property-value ?b ?prop ?val)
        [?prop-e :db/ident ?prop]
@@ -229,7 +239,7 @@
     :has-simple-query-property
     '[(has-simple-query-property ?b ?prop)
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       (has-property-or-default-value? ?b ?prop)
       [?prop-e :block/schema ?prop-schema]
       [(get ?prop-schema :public? true) ?public]
@@ -239,7 +249,7 @@
     :has-private-simple-query-property
     '[(has-private-simple-query-property ?b ?prop)
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       (has-property-or-default-value? ?b ?prop)]
 
     ;; Checks if a property exists for any features that are not simple queries
@@ -247,7 +257,7 @@
     '[(has-property ?b ?prop)
       [?b ?prop _]
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       [?prop-e :block/schema ?prop-schema]
       [(get ?prop-schema :public? true) ?public]
       [(= true ?public)]]
@@ -256,7 +266,7 @@
     :property
     '[(property ?b ?prop ?val)
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       [?prop-e :block/schema ?prop-schema]
       [(get ?prop-schema :public? true) ?public]
       [(= true ?public)]
@@ -276,7 +286,7 @@
     :simple-query-property
     '[(simple-query-property ?b ?prop ?val)
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       [?prop-e :block/schema ?prop-schema]
       [(get ?prop-schema :public? true) ?public]
       [(get ?prop-schema :type) ?type]
@@ -287,7 +297,7 @@
     :private-simple-query-property
     '[(private-simple-query-property ?b ?prop ?val)
       [?prop-e :db/ident ?prop]
-      [?prop-e :block/type "property"]
+      [?prop-e :block/tags :logseq.class/Property]
       (property-value ?b ?prop-e ?val)]
 
     :tags

+ 1 - 1
deps/db/src/logseq/db/frontend/schema.cljs

@@ -111,7 +111,7 @@
    (dissoc schema
            :block/namespace :block/properties-text-values :block/pre-block? :recent/pages :block/file
            :block/properties :block/properties-order :block/repeated? :block/deadline :block/scheduled :block/priority
-           :block/marker :block/macros)
+           :block/marker :block/macros :block/type)
    {:block/name {:db/index true}        ; remove db/unique for :block/name
     ;; closed value
     :block/closed-value-property {:db/valueType :db.type/ref

+ 2 - 23
deps/db/src/logseq/db/frontend/validate.cljs

@@ -19,32 +19,11 @@
   [closed-schema?]
   (if closed-schema? closed-db-schema-explainer db-schema-explainer))
 
-(defn validate-ents-before-after!
-  [changed-ids db-before db-after tx-data tx-meta]
-  (let [id->ent-before (into {}
-                             (keep (fn [id] (when-let [ent (d/entity db-before id)] [id ent])))
-                             changed-ids)
-        id->ent-after (keep (fn [id] (when-let [ent (d/entity db-after id)] [id ent])) changed-ids)
-        ent-before+ent-after-coll
-        (reduce
-         (fn [acc [id ent-after]]
-           (if-let [ent-before (id->ent-before id)]
-             (conj acc [ent-before ent-after])
-             acc))
-         [] id->ent-after)]
-    (doseq [[ent-before ent-after] ent-before+ent-after-coll]
-      (let [[type-before type-after] [(:block/type ent-before) (:block/type ent-after)]]
-        (when (and (some? type-before)
-                   (nil? type-after))
-          (js/console.error "Illegal :block/type change, entity id:" (:db/id ent-after))
-          (prn :ent-before ent-before :ent-after ent-after :tx-data tx-data :tx-meta tx-meta))))))
-
 (defn validate-tx-report!
   "Validates the datascript tx-report for entities that have changed. Returns
   boolean indicating if db is valid"
-  [{:keys [db-before db-after tx-data tx-meta]} validate-options]
+  [{:keys [db-after tx-data tx-meta]} validate-options]
   (let [changed-ids (->> tx-data (keep :e) distinct)
-        _ (validate-ents-before-after! changed-ids db-before db-after tx-data tx-meta)
         tx-datoms (mapcat #(d/datoms db-after :eavt %) changed-ids)
         ent-maps* (map (fn [[db-id m]]
                          ;; Add :db/id for debugging
@@ -88,7 +67,7 @@
                            (:block/page ent)
                            (update :block/page
                                    (fn [id] (select-keys (d/entity db id)
-                                                         [:block/name :block/type :db/id :block/created-at])))))
+                                                         [:block/name :block/tags :db/id :block/created-at])))))
                :errors errors'
                ;; Group by type to reduce verbosity
                ;; TODO: Move/remove this to another fn if unused

+ 4 - 4
deps/db/src/logseq/db/sqlite/build.cljs

@@ -357,7 +357,7 @@
                       {:db/id (or (:db/id page) (new-db-id))
                        :block/title (or (:block/title page) (string/capitalize (:block/name page)))
                        :block/name (or (:block/name page) (common-util/page-name-sanity-lc (:block/title page)))
-                       :block/type "page"
+                       :block/tags #{:logseq.class/Page}
                        :block/format :markdown}
                       (dissoc page :build/properties :db/id :block/name :block/title :build/tags))
             pvalue-tx-m (->property-value-tx-m new-page (:build/properties page) properties all-idents)]
@@ -376,8 +376,9 @@
                                     page-uuids
                                     all-idents))
               (when-let [tags (:build/tags page)]
-                {:block/tags (mapv #(hash-map :db/ident (get-ident all-idents %))
-                                   tags)})))))
+                {:block/tags (-> (mapv #(hash-map :db/ident (get-ident all-idents %))
+                                       tags)
+                                 (conj :logseq.class/Page))})))))
          ;; blocks tx
          (reduce (fn [acc m]
                    (into acc
@@ -480,7 +481,6 @@
                                                    :block/title page-name
                                                    :block/uuid
                                                    (common-uuid/gen-uuid :journal-page-uuid date-int)
-                                                   :block/type "journal"
                                                    :block/tags :logseq.class/Journal})))))
                            m))]
     ;; Order matters as some steps depend on previous step having prepared blocks or pages in a certain way

+ 3 - 8
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -186,7 +186,6 @@
             :in $ ?today
             :where
             [?page :block/name ?page-name]
-            ;; [?page :block/type "journal"]
             [?page :block/journal-day ?journal-day]
             [(<= ?journal-day ?today)]]
           db
@@ -213,13 +212,9 @@
 
 (defn get-structured-datoms
   [db]
-  (mapcat (fn [type']
-            (->> (d/datoms db :avet :block/type type')
-                 (mapcat (fn [d]
-                           (d/datoms db :eavt (:e d))))))
-          [;; property and class pages are pulled from `get-all-pages` already
-           ;; "property" "class"
-           "closed value"]))
+  (->> (d/datoms db :avet :block/tags :logseq.class/Closed-Value)
+       (mapcat (fn [d]
+                 (d/datoms db :eavt (:e d))))))
 
 (defn get-favorites
   "Favorites page and its blocks"

+ 7 - 5
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -10,7 +10,8 @@
             [logseq.db.frontend.schema :as db-schema]
             [logseq.db.sqlite.util :as sqlite-util]
             [logseq.common.config :as common-config]
-            [logseq.db.frontend.order :as db-order]))
+            [logseq.db.frontend.order :as db-order]
+            [logseq.db.frontend.entity-util :as entity-util]))
 
 (defn- mark-block-as-built-in [block]
   (assoc block :logseq.property/built-in? true))
@@ -52,14 +53,15 @@
                    ;; Adding built-ins must come after initial properties
                    [(mark-block-as-built-in' built-in-property)]
                    (map mark-block-as-built-in' properties)
-                   (keep #(when (= "closed value" (:block/type %)) (mark-block-as-built-in' %))
+                   (keep #(when (entity-util/closed-value? %)
+                            (mark-block-as-built-in' %))
                          properties))]
     (doseq [m tx]
       (when-let [block-uuid (and (:db/ident m) (:block/uuid m))]
         (assert (string/starts-with? (str block-uuid) "00000002") m)))
 
     {:tx tx
-     :properties (filter #(= (:block/type %) "property") properties)}))
+     :properties (filter entity-util/property? properties)}))
 
 (def built-in-pages-names
   #{"Contents"})
@@ -111,7 +113,7 @@
       {:block/uuid page-id
        :block/name common-config/views-page-name
        :block/title common-config/views-page-name
-       :block/type "page"
+       :block/tags [:logseq.class/Page]
        :block/schema {:public? false}
        :block/format :markdown
        :logseq.property/built-in? true})
@@ -131,7 +133,7 @@
     {:block/uuid (common-uuid/gen-uuid)
      :block/name common-config/favorites-page-name
      :block/title common-config/favorites-page-name
-     :block/type "page"
+     :block/tags [:logseq.class/Page]
      :block/schema {:public? false}
      :block/format :markdown
      :logseq.property/built-in? true})])

+ 3 - 3
deps/db/src/logseq/db/sqlite/util.cljs

@@ -91,7 +91,7 @@
      (block-with-timestamps
       (cond->
        {:db/ident db-ident'
-        :block/type "property"
+        :block/tags #{:logseq.class/Property}
         :block/format :markdown
         :block/schema (merge {:type :default} (dissoc prop-schema :classes :cardinality))
         :block/name (common-util/page-name-sanity-lc (name prop-name))
@@ -115,7 +115,7 @@
   {:pre [(qualified-keyword? (:db/ident block))]}
   (block-with-timestamps
    (cond-> (merge block
-                  {:block/type "class"
+                  {:block/tags #{:logseq.class/Class}
                    :block/format :markdown})
      (and (not= (:db/ident block) :logseq.class/Root)
           (nil? (:logseq.property/parent block)))
@@ -129,7 +129,7 @@
     :block/title page-name
     :block/uuid (d/squuid)
     :block/format :markdown
-    :block/type "page"}))
+    :block/tags #{:logseq.class/Page}}))
 
 (defn kv
   "Creates a key-value pair tx with the key and value respectively stored under

+ 4 - 4
deps/db/test/logseq/db/sqlite/build_test.cljs

@@ -12,14 +12,14 @@
            [{:page {:block/title "page1"}
              :blocks [{:block/title "Jrue Holiday" :build/tags [:Person]}]}
             {:page {:block/title "Jayson Tatum" :build/tags [:Person]}}])]
-    (is (= {:block/tags [{:block/title "Person", :block/type "class"}]}
-           (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
+    (is (= {:block/tags [{:block/title "Person", :block/tags [{:block/title "Tag"}]}]}
+           (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/tags]}]) ...]
                          :where [?b :block/title "Jrue Holiday"]]
                        @conn)))
         "Person class is created and correctly associated to a block")
 
-    (is (= {:block/tags [{:block/title "Person", :block/type "class"}]}
-           (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
+    (is (= {:block/tags [{:block/title "Person", :block/tags [{:block/title "Tag"}]}]}
+           (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/tags]}]) ...]
                          :where [?b :block/title "Jayson Tatum"]]
                        @conn)))
         "Person class is created and correctly associated to a page")))

+ 3 - 3
deps/db/test/logseq/db/sqlite/create_graph_test.cljs

@@ -14,7 +14,7 @@
 (deftest new-graph-db-idents
   (testing "a new graph follows :db/ident conventions for"
     (let [conn (db-test/create-conn)
-          ident-ents (->> (d/q '[:find (pull ?b [:db/ident :block/type])
+          ident-ents (->> (d/q '[:find (pull ?b [:db/ident :block/tags])
                                  :where [?b :db/ident]]
                                @conn)
                           (map first))
@@ -38,7 +38,7 @@
                                            (map #(keyword (namespace %) (string/replace (name %) #".[^.]+$" "")))
                                            set)]
           (is (= []
-                 (remove #(= "closed value" (:block/type %)) closed-value-ents))
+                 (remove ldb/closed-value? closed-value-ents))
               "All property names that contain a '.' are closed values")
           (is (= #{}
                  (set/difference
@@ -56,7 +56,7 @@
                     (remove #(or (= "logseq.kv" (namespace (:db/ident %)))
                                  (= :logseq.property/empty-placeholder (:db/ident %)))))
         pages (d/q '[:find [(pull ?b [:logseq.property/built-in? :block/title]) ...]
-                     :where [?b :block/type "page"]]
+                     :where [?b :block/tags :logseq.class/Page]]
                    @conn)]
     (is (= [] (remove :logseq.property/built-in? idents))
         "All entities with :db/ident have built-in property (except for kv idents)")

+ 4 - 4
deps/db/test/logseq/db_test.cljs

@@ -29,16 +29,16 @@
                   (ex-message e)))))))
 
 (def class-parents-data
-  [{:block/type "class"
+  [{:block/tags :logseq.class/Class
     :block/title "x"
     :block/name "x"
     :block/uuid #uuid "6c353967-f79b-4785-b804-a39b81d72461"}
-   {:block/type "class"
+   {:block/tags :logseq.class/Class
     :block/title "y"
     :block/name "y"
     :block/uuid #uuid "7008db08-ba0c-4aa9-afc6-7e4783e40a99"
     :logseq.property/parent [:block/uuid #uuid "6c353967-f79b-4785-b804-a39b81d72461"]}
-   {:block/type "class"
+   {:block/tags :logseq.class/Class
     :block/title "z"
     :block/name "z"
     :block/uuid #uuid "d95f2912-a7af-41b9-8ed5-28861f7fc0be"
@@ -63,4 +63,4 @@
     (is (= "Foo" (:block/title (ldb/get-case-page @conn "Foo"))))
     ;; Case sensitive classes
     (is (= "movie" (:block/title (ldb/get-case-page @conn "movie"))))
-    (is (= "Movie" (:block/title (ldb/get-case-page @conn "Movie"))))))
+    (is (= "Movie" (:block/title (ldb/get-case-page @conn "Movie"))))))

+ 7 - 11
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -113,7 +113,7 @@
   (if block-ns
     (->> (d/q '[:find [?b ...]
                 :in $ ?name
-                :where [?b :block/uuid ?uuid] [?b :block/type "class"] [?b :block/name ?name]]
+                :where [?b :block/uuid ?uuid] [?b :block/tags :logseq.class/Class] [?b :block/name ?name]]
               db
               (ns-util/get-last-part full-name))
          (map #(d/entity db %))
@@ -125,7 +125,7 @@
     (first
      (d/q '[:find [?uuid ...]
             :in $ ?name
-            :where [?b :block/uuid ?uuid] [?b :block/type "class"] [?b :block/name ?name]]
+            :where [?b :block/uuid ?uuid] [?b :block/tags :logseq.class/Class] [?b :block/name ?name]]
           db
           full-name))))
 
@@ -295,7 +295,6 @@
                                            (date-time-util/int->journal-title date-int (common-config/get-date-formatter user-config)))]
                                (assoc page-m
                                       :block/uuid (common-uuid/gen-uuid :journal-page-uuid date-int)
-                                      :block/type "journal"
                                       :block/journal-day date-int)))
                          (assoc :block/tags :logseq.class/Journal))]
       {:block
@@ -907,7 +906,7 @@
                 (:block/name %))
               (or (:block/uuid %)
                   (throw (ex-info (str "No uuid for existing page " (pr-str (:block/name %)))
-                                  (select-keys % [:block/name :block/type]))))))
+                                  (select-keys % [:block/name :block/tags]))))))
        (into {})))
 
 (defn- build-existing-page
@@ -915,13 +914,10 @@
   (let [;; These attributes are not allowed to be transacted because they must not change across files
         disallowed-attributes [:block/name :block/uuid :block/format :block/title :block/journal-day
                                :block/created-at :block/updated-at]
-        allowed-attributes (into [:block/tags :block/alias :logseq.property/parent :block/type :db/ident]
+        allowed-attributes (into [:block/tags :block/alias :logseq.property/parent :db/ident]
                                  (keep #(when (db-malli-schema/user-property? (key %)) (key %))
                                        m))
-        block-changes (cond-> (select-keys m allowed-attributes)
-                        ;; disallow any type -> "page" but do allow any conversion to a non-page type
-                        (ldb/internal-page? m)
-                        (dissoc :block/type))]
+        block-changes (select-keys m allowed-attributes)]
     (when-let [ignored-attrs (not-empty (apply dissoc m (into disallowed-attributes allowed-attributes)))]
       (notify-user {:msg (str "Import ignored the following attributes on page " (pr-str (:block/title m)) ": "
                               ignored-attrs)}))
@@ -952,8 +948,8 @@
             (assoc :block/uuid (d/squuid))
             ;; only happens for few file built-ins like tags and alias
             (and (contains? all-built-in-names (keyword (:block/name page)))
-                 (not (:block/type page)))
-            (assoc :block/type "page")))]
+                 (not (:block/tags page)))
+            (assoc :block/tags :logseq.class/Page)))]
     (cond-> page'
       (:block/namespace page)
       ((fn [block']

+ 1 - 2
deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs

@@ -23,7 +23,6 @@
     (sh ["git" "clone" "--depth" "1" "-b" branch "-c" "advice.detachedHead=false"
          "https://github.com/logseq/docs" dir] {})))
 
-
 ;; Fns for common test assertions
 ;; ==============================
 (defn get-top-block-properties
@@ -62,7 +61,7 @@
 (defn- get-journal-page-count [db]
   (->> (d/q '[:find (count ?b)
               :where
-              [?b :block/type "journal"]
+              [?b :block/journal-day]
               [?b :block/name]
               [?b :block/file]]
             db)

+ 23 - 17
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -33,14 +33,14 @@
          (d/q '[:find [(pull ?b [*]) ...]
                 :in $ ?pattern
                 :where [?b :block/title ?content]
-                [(missing? $ ?b :block/type)]
+                [(missing? $ ?b :block/tags)]
                 [(re-find ?pattern ?content)]]
               db)
          first)
     (->> content
          (d/q '[:find [(pull ?b [*]) ...]
                 :in $ ?content
-                :where [?b :block/title ?content] [(missing? $ ?b :block/type)]]
+                :where [?b :block/title ?content] [(missing? $ ?b :block/tags)]]
               db)
          first)))
 
@@ -195,7 +195,6 @@
 
       ;; Counts
       ;; Includes journals as property values e.g. :logseq.task/deadline
-      (is (= 24 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
       (is (= 24 (count (d/q '[:find ?b :where [?b :block/tags :logseq.class/Journal]] @conn))))
 
       (is (= 4 (count (d/q '[:find ?b :where [?b :block/tags :logseq.class/Task]] @conn))))
@@ -204,16 +203,16 @@
 
       ;; Don't count pages like url.md that have properties but no content
       (is (= 10
-             (count (->> (d/q '[:find [(pull ?b [:block/title :block/type]) ...]
+             (count (->> (d/q '[:find [(pull ?b [:block/title :block/tags]) ...]
                                 :where [?b :block/title] [_ :block/page ?b] (not [?b :logseq.property/built-in?])] @conn)
                          (filter ldb/internal-page?))))
           "Correct number of pages with block content")
       (is (= 11 (->> @conn
                      (d/q '[:find [?ident ...]
-                            :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
+                            :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
                      count))
           "Correct number of user classes")
-      (is (= 4 (count (d/datoms @conn :avet :block/type "whiteboard"))))
+      (is (= 4 (count (d/datoms @conn :avet :block/tags :logseq.class/Whiteboard))))
       (is (= 0 (count @(:ignored-properties import-state))) ":filters should be the only ignored property")
       (is (= 1 (count @assets))))
 
@@ -236,7 +235,7 @@
       (is (= 18
              (->> @conn
                   (d/q '[:find [(pull ?b [:db/ident]) ...]
-                         :where [?b :block/type "property"]])
+                         :where [?b :block/tags :logseq.class/Property]])
                   (remove #(db-malli-schema/internal-ident? (:db/ident %)))
                   count))
           "Correct number of user properties")
@@ -248,7 +247,7 @@
                {:db/ident :user.property/startedat :block/schema {:type :date}}}
              (->> @conn
                   (d/q '[:find [(pull ?b [:db/ident :block/schema]) ...]
-                         :where [?b :block/type "property"]])
+                         :where [?b :block/tags :logseq.class/Property]])
                   (filter #(contains? #{:prop-bool :prop-string :prop-num :rangeincludes :sameas :startedat}
                                       (keyword (name (:db/ident %)))))
                   set))
@@ -362,8 +361,12 @@
              (:db/ident (find-page-by-name @conn "life")))
           "Namespaced tag's ident has hierarchy to make it unique")
 
-      (is (= [{:block/type "class"}]
-             (d/q '[:find [(pull ?b [:block/type]) ...] :where [?b :block/name "life"]] @conn))
+      (is (= ["Tag"]
+             (d/q '[:find [?t-title ...]
+                    :where
+                    [?b :block/name "life"]
+                    [?b :block/tags ?t]
+                    [?t :block/title ?t-title]] @conn))
           "When a class is used and referenced on the same page, there should only be one instance of it")
 
       (is (= ["life"]
@@ -442,8 +445,11 @@
       (is (= #{:logseq.property/description :user.property/description}
              (set (d/q '[:find [?ident ...] :where [?b :db/ident ?ident] [?b :block/name "description"]] @conn)))
           "user description property is separate from built-in one")
-      (is (= #{"page" "class"}
-             (set (d/q '[:find [?type ...] :where [?b :block/type ?type] [?b :block/name "task"]] @conn)))
+      (is (= #{"Page" "Class"}
+             (set (d/q '[:find [?t-title ...] :where
+                         [?b :block/tags ?t]
+                         [?b :block/name "task"]
+                         [?t :block/title ?t-title]] @conn)))
           "user page is separate from built-in class"))
 
     (testing "multiline blocks"
@@ -495,7 +501,7 @@
     (is (= 0 (count @(:ignored-properties import-state))) "No ignored properties")
     (is (= 0 (->> @conn
                   (d/q '[:find [?ident ...]
-                         :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
+                         :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
                   count))
         "Correct number of user classes")
 
@@ -556,7 +562,7 @@
              (:block/tags (readable-properties @conn block)))
           "tagged block has configured tag imported as a class")
 
-      (is (= "class" (:block/type tag-page))
+      (is (= :logseq.class/Class (:db/ident (first (:block/tags tag-page))))
           "configured tag page in :tag-classes is a class")
       (is (and another-tag-page (not (ldb/class? another-tag-page)))
           "unconfigured tag page is not a class")
@@ -580,7 +586,7 @@
     (is (= #{:user.class/Property :user.class/Movie :user.class/Class :user.class/Tool}
            (->> @conn
                 (d/q '[:find [?ident ...]
-                       :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
+                       :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
                 set))
         "All classes are correctly defined by :type")
 
@@ -602,7 +608,7 @@
           "tagged block can have another property that references the same class it is tagged with,
            without creating a duplicate class")
 
-      (is (= "class" (:block/type tag-page))
+      (is (= :logseq.class/Class (:db/ident (first (:block/tags tag-page))))
           "configured tag page derived from :property-classes is a class")
       (is (nil? (find-page-by-name @conn "type"))
           "No page exists for configured property")
@@ -648,7 +654,7 @@
              :user.class/Class :user.class/Tool :user.class/Whiteboard___Tool}
            (->> @conn
                 (d/q '[:find [?ident ...]
-                       :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
+                       :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
                 set))
         "All classes are correctly defined by :type")
 

+ 5 - 5
deps/outliner/src/logseq/outliner/validate.cljs

@@ -49,13 +49,13 @@
                                 :in $ ?eid ?title
                                 :where
                                 [?b :block/title ?title]
-                                [?b :block/type "property"]
+                                [?b :block/tags :logseq.class/Property]
                                 [(not= ?b ?eid)]]
                               '[:find [?b ...]
                                 :in $ ?eid ?title
                                 :where
                                 [?b :block/title ?title]
-                                [?b :block/type "property"]
+                                [?b :block/tags :logseq.class/Property]
                                 [(missing? $ ?b :logseq.property/built-in?)]
                                 [(not= ?b ?eid)]])
                             db
@@ -113,14 +113,14 @@
 
     :else
     (when-let [_res (seq (d/q '[:find [?b ...]
-                                :in $ ?eid ?type ?title
+                                :in $ ?eid [?tag ...] ?title
                                 :where
                                 [?b :block/title ?title]
-                                [?b :block/type ?type]
+                                [?b :block/tags ?tag]
                                 [(not= ?b ?eid)]]
                               db
                               (:db/id entity)
-                              (:block/type entity)
+                              (map :db/id (:block/tags entity))
                               new-title))]
       (throw (ex-info "Duplicate page without tag"
                       {:type :notification

+ 4 - 3
deps/outliner/test/logseq/outliner/pipeline_test.cljs

@@ -13,9 +13,10 @@
 (defn- get-blocks [db]
   (->> (d/q '[:find (pull ?b [* {:block/path-refs [:block/name :db/id]}])
               :in $
-              :where [?b :block/title]
-              [(missing? $ ?b :logseq.property/built-in?)]
-              [(missing? $ ?b :block/type)]]
+              :where
+              [?b :block/page]
+              [?b :block/title]
+              [(missing? $ ?b :logseq.property/built-in?)]]
             db)
        (map first)))
 

+ 3 - 2
deps/outliner/test/logseq/outliner/property_test.cljs

@@ -3,7 +3,8 @@
             [datascript.core :as d]
             [logseq.outliner.property :as outliner-property]
             [logseq.db.frontend.property :as db-property]
-            [logseq.db.test.helper :as db-test]))
+            [logseq.db.test.helper :as db-test]
+            [logseq.db :as ldb]))
 
 (deftest upsert-property!
   (testing "Creates a property"
@@ -228,7 +229,7 @@
     (testing "Add choice successfully"
       (let [_ (outliner-property/upsert-closed-value! conn :user.property/num {:value 3})
             b (first (d/q '[:find [(pull ?b [*]) ...] :where [?b :property.value/content 3]] @conn))]
-        (is (= (:block/type b) "closed value"))
+        (is (ldb/closed-value? (d/entity @conn (:db/id b))))
         (is (= [2 3]
                (map db-property/closed-value-content (:block/_closed-value-property (d/entity @conn :user.property/num)))))))
 

+ 1 - 1
scripts/src/logseq/tasks/db_graph/create_graph_with_schema_org.cljs

@@ -376,7 +376,7 @@
                             (map (fn [m]
                                    (let [props (->> (db-property/properties m)
                                                     (into {}))]
-                                     (cond-> (select-keys m [:block/name :block/type :block/title :block/schema :db/ident
+                                     (cond-> (select-keys m [:block/name :block/tags :block/title :block/schema :db/ident
                                                              :logseq.property.class/properties :logseq.property/parent
                                                              :db/cardinality :property/schema.classes :block/refs])
                                        (seq props)