 
           (recur next-el-loc deconstruction))))))
 
-(defn whole-node
-  "No deconstruction performed"
-  [file-path el-loc]
-  [[file-path (cdx/indent-str (cz/node el-loc))]])
-
 (defmethod mi/deconstruct-node :default [_ file-path el-loc]
-  (whole-node file-path el-loc))
+  [[file-path (cdx/indent-str (cz/node el-loc))]]) ;; just return whole node
 
 (defmethod mi/deconstruct-node :global-scripts [_ file-path el-loc]
   (deconstruct-node

     (when-let [name-loc (cdzx/xml1-> el-loc :entry :string)]
       [(cdzx/text name-loc) (cz/right name-loc)]))))

(def channel-deconstructors
  [[#(cdzx/xml1-> % :connector :name cdzx/text)
    #(cdzx/xml1-> % :connector :properties :script)]
   [#(cdzx/xml1-> % :sourceConnector :name cdzx/text)
    #(cdzx/xml1-> % :sourceConnector :properties :script)]
   [(fn [_] "PreprocessingScript")
    #(cdzx/xml1-> % :preprocessingScript)]
   [(fn [_] "PostprocessingScript")
    #(cdzx/xml1-> % :postprocessingScript)]
   [(fn [_] "DeployScript")
    #(cdzx/xml1-> % :deployScript)]
   [(fn [_] "UndeployScript")
    #(cdzx/xml1-> % :undeployScript)]])

(defmethod mi/deconstruct-node :channels [_ file-path el-loc]
  (deconstruct-node

   (fn [el-loc]
     (some (fn [[name script]]
             (when-let [script-loc (script el-loc)]
               [(name script-loc) script-loc]))
           channel-deconstructors))))

(comment

  ;; pull
  (mirthsync.core/main-func "-s" "https://localhost:8443/api"
                            "-u" "admin" "-p" "admin" "-t" "target/tmp"
                            "-i" "-f" "pull")

  ;; load a channel for repl work
  (def el-loc2 (cz/xml-zip (cdx/parse-str (slurp "target/tmp/Channels/This is a group/Hello DB Writer.xml"))))

  ;; select first transformer elements
  (cdzx/xml1-> el-loc2 :sourceConnector :transformer :elements cz/node)

  (def first-transformer-jscript-step
    (cdzx/xml1-> el-loc2
                 :sourceConnector
                 :transformer
                 :elements
                 :com.mirth.connect.plugins.javascriptstep.JavaScriptStep
                 :script
                 [cz/up cz/up cz/up :transformer cz/up :sourceConnector]))
)
