Browse Source

fix: update schema to include new enum value block

Part of LOG-2871.
Also fixed create-graph failing due to renamed ns
Gabriel Horner 2 years ago
parent
commit
5f392a2260

+ 19 - 9
deps/db/src/logseq/db/frontend/malli_schema.cljs

@@ -174,7 +174,8 @@
   (vec
    (concat
     [:map
-     [:block/metadata
+     ;; hidden pages for enum values don't have this
+     [:block/metadata {:optional true}
       [:map
        [:source-page-id :uuid]]]]
     page-attrs
@@ -193,6 +194,7 @@
   [[:block/content :string]
    [:block/left :int]
    [:block/parent :int]
+   ;; Created when blocks are used for property values
    [:block/metadata {:optional true}
     [:map
      [:created-from-block :uuid]
@@ -222,13 +224,20 @@
     block-attrs
     (remove #(= :block/tags (first %)) page-or-block-attrs))))
 
-;; (def enum-value
-;;   "A enum item"
-;;   (vec
-;;    (concat
-;;     [:map]
-;;     [[:block/type [:= #{"enum value"}]]]
-;;     block-attrs)))
+(def enum-block
+  "An enum value for enum property"
+  (vec
+   (concat
+    [:map]
+    [[:block/type [:= #{"enum value"}]]
+     [:block/schema {:optional true}
+      [:map
+       [:description :string]]]
+     [:block/metadata
+      [:map
+       [:created-from-property :uuid]]]]
+    (remove #(= :block/metadata (first %)) block-attrs)
+    page-or-block-attrs)))
 
 (def normal-block
   "A block with content and no special type or tag behavior"
@@ -242,7 +251,8 @@
   "A block has content and a page"
   [:or
    normal-block
-   object-block])
+   object-block
+   enum-block])
 
 ;; TODO: invalid macros should not generate unknown
 (def unknown-block

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

@@ -5,7 +5,7 @@
   graph and current limitations"
   (:require [logseq.db.sqlite.db :as sqlite-db]
             [logseq.db.sqlite.util :as sqlite-util]
-            [logseq.tasks.db-graph.persist-graph :as persist-graph]
+            [logseq.outliner.cli.persist-graph :as persist-graph]
             [logseq.db :as ldb]
             [clojure.string :as string]
             [datascript.core :as d]