Skip to content
5 changes: 4 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
:dev [:profiles/dev
{:plugins [[lein-midje "3.2.1"]]
:dependencies [[midje "1.9.6"]
[nubank/matcher-combinators "0.9.0"]]}]
[lambdaisland/kaocha-midje "0.0-5"
:exclusions [midje/midje]]
[nubank/matcher-combinators "0.9.0"]]}]
:test
{:resource-paths ["test/resources"]
:env {:yb-adapters-freenode-type "irc"
Expand Down Expand Up @@ -128,6 +130,7 @@
[json-path "1.0.1"]

; utils
[org.clojure/data.codec "0.1.1"] ; base64
[funcool/cuerdas "2.1.0"]
[clj-stacktrace "0.2.8"]
[clj-fuzzy "0.4.1"]
Expand Down
312 changes: 169 additions & 143 deletions resources/graphql-schema.edn
Original file line number Diff line number Diff line change
@@ -1,149 +1,175 @@
{:objects {:adapter {:fields {:uuid {:type String}
:platform {:type String}
:is_connected {:type Boolean}
:connection_latency {:type Int}
:connection_last_active_timestamp {:type String}
}}

:history {:fields
{:chat_source_adapter {:type String}
:chat_source_room {:type String}
:user {:type :user
:resolve :user}
:user_id {:type String}
:user_name {:type String}
:body {:type String}
:is_command {:type Boolean}
:is_yetibot {:type Boolean}
:id {:type Int}
:command {:type String}
:correlation_id {:type String}
:created_at {:type String}}}

:stats {:fields
{:uptime {:type String}
:adapter_count {:type Int}
:user_count {:type Int}
:history_count {:type Int}
:history_count_today {:type Int}
:command_count_today {:type Int}
:command_count {:type Int}
:alias_count {:type Int}
:observer_count {:type Int}
:cron_count {:type Int}
}}

:user {:fields
{:username {:type String}
:is_active {:type Boolean}
:id {:type String}
:last_active {:type String}
:karma {:type Int}}}

:alias {:fields
{:id {:type Int}
:user_id {:type String}
:cmd_name {:type String}
:cmd {:type String}
:created_at {:type String}}}

:observer {:fields
{:id {:type Int}
:user_id {:type String}
:pattern {:type String}
:user_pattern {:type String}
:channel_pattern {:type String}
:event_type {:type String}
:cmd {:type String}
:created_at {:type String}}}

:cron {:fields
{:id {:type Int}
:created_at {:type String}
:chat_source_adapter {:type String}
:chat_source_room {:type String}
:user_id {:type String}
:schedule {:type String}
:cmd {:type String}}}

;; TODO list channels by adapter
:adapter_channel {:fields
{:adapter {:type String}
:channel {:type String}}}

:channel {:fields
{:name {:type String}}}

:karma {:fields
{:user_id {:type String}
:score {:type Int}}}
}
{:objects
{:history {:fields
{:chat_source_adapter {:type String}
:chat_source_room {:type String}
:user {:type :user
:resolve :user}
:user_id {:type String}
:user_name {:type String}
:body {:type String}
:is_command {:type Boolean}
:is_yetibot {:type Boolean}
:id {:type Int}
:command {:type String}
:correlation_id {:type String}
:created_at {:type String}}}

:page_info {:fields
{:total_results {:type Int}
:next_page_cursor {:type String}
:has_next_page {:type Boolean}}}

:paged_history {:fields
{:page_info {:type :page_info}
:history {:type (list :history)}}}

:adapter {:fields {:uuid {:type String}
:platform {:type String}
:is_connected {:type Boolean}
:connection_latency {:type Int}
:connection_last_active_timestamp {:type String}}}

:stats {:fields
{:uptime {:type String}
:adapter_count {:type Int}
:user_count {:type Int}
:history_count {:type Int}
:history_count_today {:type Int}
:command_count_today {:type Int}
:command_count {:type Int}
:alias_count {:type Int}
:observer_count {:type Int}
:cron_count {:type Int}
}}

:user {:fields
{:username {:type String}
:is_active {:type Boolean}
:id {:type String}
:last_active {:type String}
:karma {:type Int}}}

:alias {:fields
{:id {:type Int}
:user_id {:type String}
:cmd_name {:type String}
:cmd {:type String}
:created_at {:type String}}}

:observer {:fields
{:id {:type Int}
:user_id {:type String}
:pattern {:type String}
:user_pattern {:type String}
:channel_pattern {:type String}
:event_type {:type String}
:cmd {:type String}
:created_at {:type String}}}

:cron {:fields
{:id {:type Int}
:created_at {:type String}
:chat_source_adapter {:type String}
:chat_source_room {:type String}
:user_id {:type String}
:schedule {:type String}
:cmd {:type String}}}

:adapter_channel {:fields
{:chat_source_adapter {:type String}
:channels {:type (list :channel)}}}

:channel {:fields
{:chat_source_adapter {:type String}
:chat_source_room {:type String}}}

:karma {:fields
{:user_id {:type String}
:score {:type Int}}}}

:enums {:karma_report {:values [{:enum-value :SCORES
:description "Users with the most amassed karma"}
{:enum-value :GIVERS
:description "User who have bestored the most karma"}]}}

:queries {:eval {:type (list String)
:args {:expr {:type String}}
:resolve :eval}

:adapters {:type (list :adapter)
:resolve :adapters}

:history {:type (list :history)
:resolve :history
:args {:limit {:type Int
:default-value 20}
:offset {:type Int
:default-value 0}
:chat_source_adapter {:type String}
:chat_source_room {:type String}
:commands_only {:type Boolean
:default-value false}
:yetibot_only {:type Boolean
:default-value false}
:search_query {:type String
:default-value nil}
:user_filter {:type String
:default-value nil}
:channel_filter {:type String
:default-value nil}
}}

:history_item {:type :history
:resolve :history_item
:args {:id {:type Int}}}

:channels {:type (list :channel)
:resolve :channels}

:users {:type (list :user)
:resolve :users}

:user {:type :user
:resolve :user
:args {:id {:type String}}}

:stats {:type :stats
:resolve :stats
:args {:timezone_offset_hours {:type Int
;; default UTC
:default-value 0}
}}

:aliases {:type (list :alias)
:resolve :aliases}

:observers {:type (list :observer)
:resolve :observers}

:crons {:type (list :cron)
:resolve :crons}

:karmas {:type (list :karma)
:resolve :karmas
:args {:report {:type :karma_report}
:limit {:type Int
:default-value 10}}}
}}
:queries
{:eval {:type (list String)
:args {:expr {:type String}}
:resolve :eval}

;; info about the configured adapters and their connection status
;; :adapters
:adapters {:type (list :adapter)
:resolve :adapters}

;; the list of channels by adapter
:adapter_channels {:type (list :adapter_channel)
:resolve :adapter_channels}

:history {:type :paged_history
:resolve :history
:args {;; pagination
:first {:type Int
:default-value 50}
:cursor {:type String
:default-value nil}

;; filtering
:include_history_commands {:type Boolean
:default-value false}
:exclude_yetibot {:type Boolean
:default-valule false}
:exclude_commands {:type Boolean
:default-valule false}
:exclude_non_commands {:type Boolean
:default-valule false}

:search_query {:type String
:default-value nil}
:users_filter {:type (list String)
:default-value nil}
:adapters_filter {:type (list String)
:default-value nil}
:channels_filter {:type (list String)
:default-value nil}
;; date filtering
:until_datetime {:type String
:default-value nil}
:since_datetime {:type String
:default-value nil}
}}

:history_item {:type :history
:resolve :history_item
:args {:id {:type Int}}}

:users {:type (list :user)
:resolve :users}

:user {:type :user
:resolve :user
:args {:id {:type String}}}

:stats {:type :stats
:resolve :stats
:args {:timezone_offset_hours {:type Int
;; default UTC
:default-value 0}
}}

:aliases {:type (list :alias)
:resolve :aliases}

:observers {:type (list :observer)
:resolve :observers}

:crons {:type (list :cron)
:resolve :crons}

:karmas {:type (list :karma)
:resolve :karmas
:args {:report {:type :karma_report}
:limit {:type Int
:default-value 10}}}

}}
3 changes: 2 additions & 1 deletion src/yetibot/core/chat.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
:uuid (a/uuid *adapter*)})

(defn chat-source
"Data structure representing the chat adapter and channel that a message came from"
"Data structure representing the chat adapter and channel that a message came
from"
[channel] (merge (base-chat-source) {:room channel}))

; (defn set-room-broadcast [room broadcast?] ((:set-room-broadcast *messaging-fns*) room broadcast?))
Expand Down
Loading