          (fn [_ data] (go (>! ch data))))))
 
 (defn clean-tree! [data]
-  (let [tj (tree->js (schema->tree (:schema (:__unversioned__ (:schemas data)))))
+  (let [tj (tree->js (schema->tree (:schema data)))
         cd (clj->js {:core {:data tj}})
         t (.jstree ($ :#tree) true)]
     (set! (.-data (.-core (.-settings t))) cd)

                      " [next] (conj old next)"
                      ")))"))
        iv (if (empty? group-bys) "[]" "{}")]
    [iv (str "(fn [prev next] " (if (empty? selects) action
                                    (str "(" let-body action ")"))
             ")")]))

(def action-mappings {:group-by "Group by"
                      :select "Select"})

                                % {:text (:analyse-stream data)}) %)
                             (:streams data))))))))

(defn list-versions [data owner]
  (reify
    om/IWillReceiveProps
    (will-receive-props [_ next-props]
      (let [svs (om/get-node owner "schema-version-select")
            cv (cljs.reader/read-string (.-value svs))]
        (when-not (contains? (:schemas (:schema next-props)) cv)
          (om/update-state!
           (:owner next-props)
           (fn [old]
             (assoc old :analyse-version (first (keys (:schemas (:schema next-props))))))))))
    om/IRender
    (render [_]
      (dom/div nil
               (dom/p nil "Schema version:")
               (apply dom/select
                      #js {:ref "schema-version-select"
                           :onChange
                           (fn [x]
                             (om/update-state!
                              (:owner data)
                              (fn [old]
                                (assoc old :analyse-version
                                       (cljs.reader/read-string (.-value (.-target x)))))))}
                      (map #(dom/option
                             (add-select-state (pr-str %) nil) (pr-str %))
                           (keys (:schemas (:schema data)))))))))

(def type-mappings {"s/Str" "string"
                    "s/Num" "num"
                    {:_ nil} "null"
