(ns db-import "Imports given file(s) to a db graph. This script is primarily for developing the import feature and for engineers who want to customize the import process" (:require [clojure.string :as string] [datascript.core :as d] ["path" :as node-path] ["os" :as os] ["fs" :as fs] ["fs/promises" :as fsp] [nbb.core :as nbb] [babashka.cli :as cli] [logseq.graph-parser.exporter :as gp-exporter] [logseq.common.graph :as common-graph] #_:clj-kondo/ignore [logseq.outliner.cli :as outliner-cli] [promesa.core :as p])) (defn- build-graph-files "Given a file graph directory, return all files including assets and adds relative paths on ::rpath since paths are absolute by default and exporter needs relative paths for some operations" [dir*] (let [dir (node-path/resolve dir*)] (->> (common-graph/get-files dir) (concat (when (fs/existsSync (node-path/join dir* "assets")) (common-graph/readdir (node-path/join dir* "assets")))) (mapv #(hash-map :path % ::rpath (node-path/relative dir* %)))))) (defn- (get-in m [:ex-data :error]) ex-data :sci.impl/callstack deref)] (println (string/join "\n" (map #(str (:file %) (when (:line %) (str ":" (:line %))) " calls #'" (str (get-in % [:sci.impl/f-meta :ns]) "/" (get-in % [:sci.impl/f-meta :name]))) stack))) (println (.-stack (get-in m [:ex-data :error]))))) (def default-export-options {;; common options :rpath-key ::rpath :notify-user notify-user :