(ns bigml-nodered-core.stream
  (: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
   "WhizzML Stream"
   {:pre tasks/stream-exec}
   {:name "stream"
    :module "stream"
    :main "stream"
    :in ["event"]
    :out ["result"]
    :options
    [["Name" {:type :text,
              :value "Stream",
              :required true
              :internal true }]
     ["Endpoint"
      {:type :text
       :placeholder "bigml-streaming" 
       :help "The name of the endpoint to stream events to."}]
     ["Label"
      {:type :text
       :placeholder ""
       :help "A label to use as tag prefix"}]
     ["Event batch size"
      {:type :number
       :value 200
       :help "How many events to collect before creating a source"}]
     ["Project"
      {:type :text
       :help "The project to assign to the source"}]
     ["Event"
      {:type :json
       :placeholder
       "{}"
       :help "The events to stream."}]]}))

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