grape-slack-bot 2.1.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ require "active_support/core_ext/class/attribute"
2
+
3
+ module SlackBot
4
+ class Schema
5
+ class_attribute :registrations, instance_accessor: false, default: {}.freeze
6
+
7
+ %i[callback_storage callback_user_finder user_session_resolver event_dispatcher].each do |setting|
8
+ define_singleton_method(setting) do |value|
9
+ self.registrations = registrations.merge([setting] => [value].freeze).freeze
10
+ end
11
+ end
12
+
13
+ %i[slash_command event block_actions shortcut message_action view_closed block_suggestion].each do |route|
14
+ define_singleton_method(route) do |key, handler|
15
+ identifier = key.to_s.dup.freeze
16
+ self.registrations = registrations.merge([route, identifier].freeze => [identifier, handler].freeze).freeze
17
+ end
18
+ end
19
+
20
+ def self.options(action_id, handler)
21
+ block_suggestion(action_id, handler)
22
+ end
23
+
24
+ def self.mount(schema)
25
+ self.registrations = registrations.merge(schema.registrations).freeze
26
+ self
27
+ end
28
+ end
29
+ end
30
+
31
+ require "slack_bot/schema/registrar"
32
+ require "slack_bot/schema/slash_command_group"
33
+ require "slack_bot/schema/input_object"
34
+ require "slack_bot/schema/responses"
35
+ require "slack_bot/schema/view_owner"
36
+ require "slack_bot/schema/slack_responses"
37
+ require "slack_bot/schema/handlers"
38
+ require "slack_bot/schema/block_actions"
39
+ require "slack_bot/schema/view_submission"
data/lib/slack_bot.rb CHANGED
@@ -21,9 +21,10 @@ require "slack_bot/menu_options"
21
21
  require "slack_bot/view"
22
22
 
23
23
  require "slack_bot/pager"
24
+ require "slack_bot/schema"
24
25
 
25
26
  require "slack_bot/grape_extension"
26
27
 
27
28
  module SlackBot
28
- VERSION = "2.1.3".freeze
29
+ VERSION = "3.0.0".freeze
29
30
  end
data/sig/slack_bot.rbs CHANGED
@@ -190,7 +190,7 @@ module SlackBot
190
190
  def initialize: (?authorization_token: String) -> void
191
191
 
192
192
  def views_open: (trigger_id: String, view: Hash[String, untyped]) -> ApiResponse
193
- def views_update: (view_id: String, view: Hash[String, untyped]) -> ApiResponse
193
+ def views_update: (view_id: String, view: Hash[String, untyped], ?hash: String?) -> ApiResponse
194
194
  def views_publish: (user_id: String, view: Hash[String, untyped]) -> ApiResponse
195
195
  def chat_post_message: (channel: String, text: String, blocks: Array[Hash[String, untyped]]) -> ApiResponse
196
196
  def chat_update: (channel: String, ts: String, text: String, blocks: Array[Hash[String, untyped]]) -> ApiResponse
@@ -264,7 +264,7 @@ module SlackBot
264
264
  end
265
265
 
266
266
  def self.open_modal: (callback: Callback?, trigger_id: String, view: Hash[String, untyped]) -> SlackViewsReply
267
- def self.update_modal: (callback: Callback?, view_id: String, view: Hash[String, untyped]) -> SlackViewsReply
267
+ def self.update_modal: (callback: Callback?, view_id: String, view: Hash[String, untyped], ?hash: String?) -> SlackViewsReply
268
268
  def self.publish_view: (user_id: String, view: Hash[String, untyped], ?callback: Callback?, ?metadata: Hash[String, untyped]?) -> SlackViewsReply
269
269
 
270
270
  attr_reader current_user: untyped?
@@ -332,7 +332,7 @@ module SlackBot
332
332
  def resolve_event_user: (Hash[String, untyped] params) -> untyped?
333
333
  def events_callback: (Hash[String, untyped] params) -> untyped
334
334
  def url_verification: (Hash[String, untyped] params) -> Hash[String, String]
335
- def handle_block_actions_view: (view: Hash[String, untyped]?, user: untyped, params: Hash[String, untyped]) -> untyped
335
+ def handle_block_actions_view: (view: Hash[String, untyped]?, user: untyped, params: Hash[String, untyped], ?type: String, ?payload: Hash[String, untyped]?) -> untyped
336
336
  def handle_block_actions_message: (payload: Hash[String, untyped], user: untyped, params: Hash[String, untyped]) -> untyped
337
337
  def dispatch_event: (handler: Class, params: Hash[String, untyped], current_user: untyped) -> bool
338
338
  def route_interaction: (payload: Hash[String, untyped], user: untyped, params: Hash[String, untyped]) -> untyped
@@ -0,0 +1,126 @@
1
+ module SlackBot
2
+ module Errors
3
+ class PushModalError < SlackResponseError
4
+ end
5
+ end
6
+
7
+ module ResponseUrl
8
+ class Reply
9
+ attr_reader status: Integer
10
+ def ok?: () -> bool
11
+ end
12
+ end
13
+
14
+ class Config
15
+ def use: (singleton(Schema) schema) -> Config
16
+ alias mount use
17
+ alias block_suggestion menu_options
18
+ def shortcut: (String | Symbol callback_id, Class handler) -> void
19
+ def message_action: (String | Symbol callback_id, Class handler) -> void
20
+ def view_closed: (String | Symbol callback_id, Class handler) -> void
21
+ def find_interaction_callback: (String type, String? callback_id) -> Class?
22
+ end
23
+
24
+ class ApiClient
25
+ def views_push: (trigger_id: String, view: Hash[String | Symbol, untyped]) -> ApiResponse
26
+ def self.response_url_post: (String url, **untyped message) -> ResponseUrl::Reply
27
+ def response_url_post: (String url, **untyped message) -> ResponseUrl::Reply
28
+ end
29
+
30
+ class Interaction
31
+ def self.push_modal: (callback: Callback?, trigger_id: String, view: Hash[String | Symbol, untyped]) -> SlackViewsReply
32
+ attr_writer payload: Hash[String, untyped]
33
+ end
34
+
35
+ class Schema
36
+ type route_id = String | Symbol
37
+
38
+ def self.callback_storage: (untyped storage) -> void
39
+ def self.callback_user_finder: (Proc finder) -> void
40
+ def self.user_session_resolver: (Proc resolver) -> void
41
+ def self.event_dispatcher: (Proc dispatcher) -> void
42
+
43
+ def self.slash_command: (route_id url_token, Class handler) -> void
44
+ def self.event: (route_id event_type, Class handler) -> void
45
+ def self.block_actions: (route_id action_id, Class handler) -> void
46
+ def self.shortcut: (route_id callback_id, Class handler) -> void
47
+ def self.message_action: (route_id callback_id, Class handler) -> void
48
+ def self.view_closed: (route_id callback_id, Class handler) -> void
49
+ def self.block_suggestion: (route_id action_id, Class handler) -> void
50
+ def self.options: (route_id action_id, Class handler) -> void
51
+ def self.mount: (singleton(Schema) schema) -> singleton(Schema)
52
+
53
+ class SlashCommandGroup
54
+ def self.default_handler: () -> Class?
55
+ def self.commands: () -> Hash[Symbol, Class]
56
+ def self.default_command: (Class handler) -> void
57
+ def self.command: (route_id token, Class handler) -> void
58
+ end
59
+
60
+ class InputObject
61
+ def self.argument: (route_id name, ?(Class | ^(untyped) -> untyped) type, ?required: bool, ?default: untyped) -> void
62
+ def self.coerce: (Args args) -> Hash[Symbol, untyped]
63
+ end
64
+
65
+ module Responses
66
+ module Declaration
67
+ def respond_with: (?(:ack | :none) mode, **untyped options) -> void
68
+ end
69
+
70
+ def call: () -> untyped
71
+ def resolve: (**untyped args) -> untyped
72
+ end
73
+
74
+ module ViewOwner
75
+ module Declaration
76
+ def block_actions: (Class handler) -> void
77
+ def view_submission: (Class handler) -> void
78
+ def view_closed: (Class handler) -> void
79
+ end
80
+ end
81
+
82
+ class SlashCommand < SlackBot::Command
83
+ include Responses
84
+ extend Responses::Declaration
85
+ extend ViewOwner::Declaration
86
+
87
+ def self.input: (singleton(InputObject) klass) -> void
88
+ end
89
+
90
+ class Event < SlackBot::Event
91
+ include Responses
92
+ extend Responses::Declaration
93
+ extend ViewOwner::Declaration
94
+ end
95
+
96
+ class Interaction < SlackBot::Interaction
97
+ include Responses
98
+ extend Responses::Declaration
99
+ extend ViewOwner::Declaration
100
+ end
101
+
102
+ class BlockActions < Interaction
103
+ def self.action: (route_id action_id, ?args: Hash[Symbol, String | Symbol | ^(Hash[String, untyped]) -> untyped], ?with: Symbol | Class) -> void
104
+ end
105
+
106
+ class ViewSubmission < Interaction
107
+ def view_state: (?route_id? block_id, ?route_id? action_id) -> untyped
108
+ end
109
+
110
+ class ViewClosed < Interaction
111
+ end
112
+
113
+ class Shortcut < Interaction
114
+ end
115
+
116
+ class MessageAction < Interaction
117
+ end
118
+
119
+ class Options < SlackBot::MenuOptions
120
+ include Responses
121
+ extend Responses::Declaration
122
+
123
+ def value: () -> String?
124
+ end
125
+ end
126
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-slack-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
@@ -339,8 +339,20 @@ files:
339
339
  - lib/slack_bot/logger.rb
340
340
  - lib/slack_bot/menu_options.rb
341
341
  - lib/slack_bot/pager.rb
342
+ - lib/slack_bot/response_url.rb
343
+ - lib/slack_bot/schema.rb
344
+ - lib/slack_bot/schema/block_actions.rb
345
+ - lib/slack_bot/schema/handlers.rb
346
+ - lib/slack_bot/schema/input_object.rb
347
+ - lib/slack_bot/schema/registrar.rb
348
+ - lib/slack_bot/schema/responses.rb
349
+ - lib/slack_bot/schema/slack_responses.rb
350
+ - lib/slack_bot/schema/slash_command_group.rb
351
+ - lib/slack_bot/schema/view_owner.rb
352
+ - lib/slack_bot/schema/view_submission.rb
342
353
  - lib/slack_bot/view.rb
343
354
  - sig/slack_bot.rbs
355
+ - sig/slack_bot_schema.rbs
344
356
  homepage: https://github.com/amkisko/grape-slack-bot.rb
345
357
  licenses:
346
358
  - MIT