(ns bigml-nodered-core.find
  (:require [bigml-nodered-core.wz :as wz]
            [bigml-nodered-core.wz.tasks :as tasks]
            [bigml-nodered-core.wz.marshal :as marshal]
            [bigml-nodered-core.utils :as utils])
  (:require-macros [bigml-nodered-core.macros :as macros]))

(defn- create-node []
  (macros/create-node
   "Find node"
   tasks/wz-find
   {:name "find"
    :main "find-node"
    :in []
    :out ["resource"]
    :options [["Name" {:type :text
                       :value "Find resources"
                       :internal true
                       :required true}]
              ["Resource Type" {:type :select
                                :value "model"
                                :void-if ""
                                :query-key "resource-type"
                                :opts [["project" "Project"]
                                       ["source" "Source"]
                                       ["dataset" "Dataset"]
                                       ["model" "Model"]
                                       ["ensemble" "Ensemble"]
                                       ["logisticregression" "Logistic Regression"]
                                       ["deepnet" "Deepnet"]
                                       ["timeseries" "Time Series"]
                                       ["fusion" "Fusion"]
                                       ["evaluation" "Evaluation"]
                                       ["optiml" "OptiML"]
                                       ["cluster" "Cluster"]
                                       ["anomaly" "Anomaly"]
                                       ["association" "Association"]
                                       ["topicmodel" "Topic Model"]
                                       ["prediction" "Prediction"]
                                       ["batchprediction" "Batch Prediction"]
                                       ["forecast" "Forecast"]
                                       ["centroid" "Centroid"]
                                       ["batchcentroid" "Batch Centroid"]
                                       ["anomalyscore" "Anomaly Score"]
                                       ["batchscore" "Batch Score"]
                                       ["associationset" "Association Set"]
                                       ["topicdistribution" "Topic Distribution"]
                                       ["batchdistribution" "Batch Distribution"]
                                       ["library" "Library"]
                                       ["script" "Script"]
                                       ["execution" "Execution"]]}]
              ["Resource Name"
               {:type :text
                :value ""
                :placeholder ""
                :void-if ""
                :query-key "name__contains"}]
              ["Tag" {:type :text
                      :value ""
                      :placeholder ""
                      :void-if ""
                      :query-key "tags__in"}]
              ["Limit" {:type :number
                        :value 1
                        :placeholder 1
                        :void-if ""}]
              ["Sort field" {:type :text
                             :value ""
                             :placeholder ""
                             :void-if ""}]
              ["Order" {:type :select
                        :value "asc"
                        :opts [["asc" "Ascending"]
                               ["desc" "Descending"]]}]
              ["Reify" {:type :boolean
                        :value false 
                        :internal true}]]}))

;; (jsassoc js/module "exports" { :input input }) 
(set! (.-exports js/module) (utils/export-nodes { "find_node" (create-node)}))
