workato-connector-sdk 0.5.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +44 -24
- data/lib/workato/cli/edit_command.rb +4 -3
- data/lib/workato/cli/exec_command.rb +24 -35
- data/lib/workato/cli/generate_command.rb +4 -3
- data/lib/workato/cli/generators/connector_generator.rb +1 -0
- data/lib/workato/cli/generators/master_key_generator.rb +1 -0
- data/lib/workato/cli/main.rb +4 -2
- data/lib/workato/cli/oauth2_command.rb +6 -5
- data/lib/workato/cli/push_command.rb +5 -4
- data/lib/workato/cli/schema_command.rb +4 -3
- data/lib/workato/connector/sdk/account_properties.rb +1 -0
- data/lib/workato/connector/sdk/action.rb +78 -20
- data/lib/workato/connector/sdk/block_invocation_refinements.rb +1 -0
- data/lib/workato/connector/sdk/connection.rb +202 -44
- data/lib/workato/connector/sdk/connector.rb +200 -65
- data/lib/workato/connector/sdk/dsl/account_property.rb +1 -0
- data/lib/workato/connector/sdk/dsl/aws.rb +23 -27
- data/lib/workato/connector/sdk/dsl/call.rb +1 -0
- data/lib/workato/connector/sdk/dsl/error.rb +1 -0
- data/lib/workato/connector/sdk/dsl/http.rb +2 -7
- data/lib/workato/connector/sdk/dsl/lookup_table.rb +1 -0
- data/lib/workato/connector/sdk/dsl/time.rb +6 -0
- data/lib/workato/connector/sdk/dsl/workato_code_lib.rb +38 -0
- data/lib/workato/connector/sdk/dsl/workato_schema.rb +1 -0
- data/lib/workato/connector/sdk/dsl.rb +19 -4
- data/lib/workato/connector/sdk/errors.rb +4 -3
- data/lib/workato/connector/sdk/lookup_tables.rb +1 -0
- data/lib/workato/connector/sdk/object_definitions.rb +7 -8
- data/lib/workato/connector/sdk/operation.rb +127 -88
- data/lib/workato/connector/sdk/request.rb +45 -17
- data/lib/workato/connector/sdk/schema/field/array.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/convertors.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/date.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/date_time.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/integer.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/number.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/object.rb +1 -0
- data/lib/workato/connector/sdk/schema/field/string.rb +1 -0
- data/lib/workato/connector/sdk/schema/type/time.rb +1 -0
- data/lib/workato/connector/sdk/schema/type/unicode_string.rb +1 -0
- data/lib/workato/connector/sdk/schema.rb +1 -0
- data/lib/workato/connector/sdk/settings.rb +9 -4
- data/lib/workato/connector/sdk/summarize.rb +3 -2
- data/lib/workato/connector/sdk/trigger.rb +112 -18
- data/lib/workato/connector/sdk/version.rb +2 -1
- data/lib/workato/connector/sdk/workato_schemas.rb +1 -0
- data/lib/workato/connector/sdk/xml.rb +1 -0
- data/lib/workato/connector/sdk.rb +4 -0
- data/lib/workato/extension/array.rb +1 -0
- data/lib/workato/extension/case_sensitive_headers.rb +1 -0
- data/lib/workato/extension/currency.rb +1 -0
- data/lib/workato/extension/date.rb +1 -0
- data/lib/workato/extension/enumerable.rb +1 -0
- data/lib/workato/extension/extra_chain_cert.rb +1 -0
- data/lib/workato/extension/hash.rb +1 -0
- data/lib/workato/extension/integer.rb +1 -0
- data/lib/workato/extension/nil_class.rb +1 -0
- data/lib/workato/extension/object.rb +1 -0
- data/lib/workato/extension/phone.rb +1 -0
- data/lib/workato/extension/string.rb +9 -15
- data/lib/workato/extension/symbol.rb +1 -0
- data/lib/workato/extension/time.rb +1 -0
- data/lib/workato/testing/vcr_encrypted_cassette_serializer.rb +5 -0
- data/lib/workato/testing/vcr_multipart_body_matcher.rb +1 -0
- data/lib/workato/web/app.rb +1 -0
- data/lib/workato-connector-sdk.rb +1 -0
- metadata +64 -7
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: strict
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'securerandom'
|
@@ -5,19 +6,41 @@ require 'securerandom'
|
|
5
6
|
module Workato
|
6
7
|
module Connector
|
7
8
|
module Sdk
|
9
|
+
module SorbetTypes
|
10
|
+
WebhookSubscribeOutputHash = T.type_alias { T::Hash[T.any(String, Symbol), T.untyped] }
|
11
|
+
end
|
12
|
+
|
8
13
|
class Trigger < Operation
|
9
14
|
using BlockInvocationRefinements
|
10
15
|
|
11
|
-
|
16
|
+
sig do
|
17
|
+
params(
|
18
|
+
trigger: SorbetTypes::SourceHash,
|
19
|
+
methods: SorbetTypes::SourceHash,
|
20
|
+
connection: Connection,
|
21
|
+
object_definitions: T.nilable(ObjectDefinitions)
|
22
|
+
).void
|
23
|
+
end
|
24
|
+
def initialize(trigger:, methods: {}, connection: Connection.new, object_definitions: nil)
|
12
25
|
super(
|
13
26
|
operation: trigger,
|
14
27
|
connection: connection,
|
15
28
|
methods: methods,
|
16
|
-
settings: settings,
|
17
29
|
object_definitions: object_definitions
|
18
30
|
)
|
19
31
|
end
|
20
32
|
|
33
|
+
sig do
|
34
|
+
params(
|
35
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
36
|
+
input: SorbetTypes::OperationInputHash,
|
37
|
+
closure: T.untyped,
|
38
|
+
extended_input_schema: SorbetTypes::OperationSchema,
|
39
|
+
extended_output_schema: SorbetTypes::OperationSchema
|
40
|
+
).returns(
|
41
|
+
HashWithIndifferentAccess
|
42
|
+
)
|
43
|
+
end
|
21
44
|
def poll_page(settings = nil, input = {}, closure = nil, extended_input_schema = [],
|
22
45
|
extended_output_schema = [])
|
23
46
|
poll_proc = trigger[:poll]
|
@@ -34,8 +57,19 @@ module Workato
|
|
34
57
|
output
|
35
58
|
end
|
36
59
|
|
60
|
+
sig do
|
61
|
+
params(
|
62
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
63
|
+
input: SorbetTypes::OperationInputHash,
|
64
|
+
closure: T.untyped,
|
65
|
+
extended_input_schema: SorbetTypes::OperationSchema,
|
66
|
+
extended_output_schema: SorbetTypes::OperationSchema
|
67
|
+
).returns(
|
68
|
+
HashWithIndifferentAccess
|
69
|
+
)
|
70
|
+
end
|
37
71
|
def poll(settings = nil, input = {}, closure = nil, extended_input_schema = [], extended_output_schema = [])
|
38
|
-
events = []
|
72
|
+
events = T.let([], T::Array[T::Hash[T.any(String, Symbol), T.untyped]])
|
39
73
|
|
40
74
|
loop do
|
41
75
|
output = poll_page(settings, input, closure, extended_input_schema, extended_output_schema)
|
@@ -52,23 +86,60 @@ module Workato
|
|
52
86
|
}.with_indifferent_access
|
53
87
|
end
|
54
88
|
|
89
|
+
sig { params(input: SorbetTypes::OperationInputHash).returns(T.untyped) }
|
55
90
|
def dedup(input = {})
|
56
91
|
trigger[:dedup].call(input)
|
57
92
|
end
|
58
93
|
|
59
|
-
|
60
|
-
|
94
|
+
sig do
|
95
|
+
params(
|
96
|
+
input: SorbetTypes::OperationInputHash,
|
97
|
+
payload: T::Hash[T.any(String, Symbol), T.untyped],
|
98
|
+
extended_input_schema: SorbetTypes::OperationSchema,
|
99
|
+
extended_output_schema: SorbetTypes::OperationSchema,
|
100
|
+
headers: T::Hash[T.any(String, Symbol), T.untyped],
|
101
|
+
params: T::Hash[T.any(String, Symbol), T.untyped],
|
102
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
103
|
+
webhook_subscribe_output: SorbetTypes::WebhookSubscribeOutputHash
|
104
|
+
).returns(
|
105
|
+
HashWithIndifferentAccess
|
106
|
+
)
|
107
|
+
end
|
108
|
+
def webhook_notification(
|
109
|
+
input = {},
|
110
|
+
payload = {},
|
111
|
+
extended_input_schema = [],
|
112
|
+
extended_output_schema = [],
|
113
|
+
headers = {},
|
114
|
+
params = {},
|
115
|
+
settings = nil,
|
116
|
+
webhook_subscribe_output = {}
|
117
|
+
)
|
118
|
+
connection.merge_settings!(settings) if settings
|
61
119
|
Dsl::WithDsl.execute(
|
120
|
+
connection,
|
62
121
|
input.with_indifferent_access,
|
63
122
|
payload.with_indifferent_access,
|
64
|
-
extended_input_schema.map(&:with_indifferent_access),
|
65
|
-
extended_output_schema.map(&:with_indifferent_access),
|
123
|
+
Array.wrap(extended_input_schema).map(&:with_indifferent_access),
|
124
|
+
Array.wrap(extended_output_schema).map(&:with_indifferent_access),
|
66
125
|
headers.with_indifferent_access,
|
67
126
|
params.with_indifferent_access,
|
127
|
+
connection.settings,
|
128
|
+
webhook_subscribe_output.with_indifferent_access,
|
68
129
|
&trigger[:webhook_notification]
|
69
|
-
)
|
130
|
+
).with_indifferent_access
|
70
131
|
end
|
71
132
|
|
133
|
+
sig do
|
134
|
+
params(
|
135
|
+
webhook_url: String,
|
136
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
137
|
+
input: SorbetTypes::OperationInputHash,
|
138
|
+
recipe_id: String
|
139
|
+
).returns(
|
140
|
+
SorbetTypes::WebhookSubscribeOutputHash
|
141
|
+
)
|
142
|
+
end
|
72
143
|
def webhook_subscribe(webhook_url = '', settings = nil, input = {}, recipe_id = SecureRandom.uuid)
|
73
144
|
webhook_subscribe_proc = trigger[:webhook_subscribe]
|
74
145
|
execute(settings, { input: input, webhook_url: webhook_url, recipe_id: recipe_id }) do |connection, payload|
|
@@ -82,6 +153,7 @@ module Workato
|
|
82
153
|
end
|
83
154
|
end
|
84
155
|
|
156
|
+
sig { params(webhook_subscribe_output: SorbetTypes::WebhookSubscribeOutputHash).returns(T.untyped) }
|
85
157
|
def webhook_unsubscribe(webhook_subscribe_output = {})
|
86
158
|
webhook_unsubscribe_proc = trigger[:webhook_unsubscribe]
|
87
159
|
execute(nil, webhook_subscribe_output) do |_connection, input|
|
@@ -89,29 +161,51 @@ module Workato
|
|
89
161
|
end
|
90
162
|
end
|
91
163
|
|
92
|
-
|
164
|
+
sig do
|
165
|
+
params(
|
166
|
+
input: SorbetTypes::OperationInputHash,
|
167
|
+
payload: T::Hash[T.any(String, Symbol), T.untyped],
|
168
|
+
headers: T::Hash[T.any(String, Symbol), T.untyped],
|
169
|
+
params: T::Hash[T.any(String, Symbol), T.untyped],
|
170
|
+
webhook_subscribe_output: SorbetTypes::WebhookSubscribeOutputHash
|
171
|
+
).returns(
|
172
|
+
T::Hash[T.any(String, Symbol), T.untyped]
|
173
|
+
)
|
174
|
+
end
|
175
|
+
def invoke(input = {}, payload = {}, headers = {}, params = {}, webhook_subscribe_output = {})
|
93
176
|
extended_schema = extended_schema(nil, input)
|
94
177
|
config_schema = Schema.new(schema: config_fields_schema)
|
95
178
|
input_schema = Schema.new(schema: extended_schema[:input])
|
96
179
|
output_schema = Schema.new(schema: extended_schema[:output])
|
97
180
|
|
98
181
|
input = apply_input_schema(input, config_schema + input_schema)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
182
|
+
if webhook_notification?
|
183
|
+
webhook_notification(
|
184
|
+
input,
|
185
|
+
payload,
|
186
|
+
input_schema,
|
187
|
+
output_schema,
|
188
|
+
headers,
|
189
|
+
params,
|
190
|
+
nil,
|
191
|
+
webhook_subscribe_output
|
192
|
+
).tap do |event|
|
193
|
+
apply_output_schema(event, output_schema)
|
194
|
+
end
|
195
|
+
else
|
196
|
+
output = poll(nil, input, nil, input_schema, output_schema)
|
197
|
+
output[:events].each do |event|
|
198
|
+
apply_output_schema(event, output_schema)
|
199
|
+
end
|
200
|
+
output
|
106
201
|
end
|
107
|
-
|
108
|
-
output
|
109
202
|
end
|
110
203
|
|
111
204
|
private
|
112
205
|
|
113
206
|
alias trigger operation
|
114
207
|
|
208
|
+
sig { returns(T::Boolean) }
|
115
209
|
def webhook_notification?
|
116
210
|
trigger[:webhook_notification].present?
|
117
211
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Workato
|
@@ -164,7 +165,7 @@ module Workato
|
|
164
165
|
end
|
165
166
|
|
166
167
|
def from_xml
|
167
|
-
|
168
|
+
Connector::Sdk::Xml.parse_xml_to_hash self
|
168
169
|
end
|
169
170
|
|
170
171
|
TO_COUNTRY_METHODS.each do |suffix|
|
@@ -229,6 +230,10 @@ module Workato
|
|
229
230
|
self
|
230
231
|
end
|
231
232
|
|
233
|
+
def to_json(_options = nil)
|
234
|
+
summary
|
235
|
+
end
|
236
|
+
|
232
237
|
def binary?
|
233
238
|
true
|
234
239
|
end
|
@@ -245,19 +250,12 @@ module Workato
|
|
245
250
|
as_string('utf-8')
|
246
251
|
end
|
247
252
|
|
248
|
-
# representation in event title
|
249
|
-
def title
|
250
|
-
if length.positive?
|
251
|
-
"0x#{byteslice(0, TITLE_LENGTH).unpack1('H*')}#{bytesize > TITLE_LENGTH ? '…' : ''}"
|
252
|
-
else
|
253
|
-
''
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
253
|
def sha1
|
258
254
|
Binary.new(::Digest::SHA1.digest(self))
|
259
255
|
end
|
260
256
|
|
257
|
+
private
|
258
|
+
|
261
259
|
def summary
|
262
260
|
if length.positive?
|
263
261
|
left = "0x#{byteslice(0, SUMMARY_LENGTH).unpack1('H*')}"
|
@@ -267,12 +265,8 @@ module Workato
|
|
267
265
|
''
|
268
266
|
end
|
269
267
|
end
|
270
|
-
|
271
|
-
def self.from_base64(base64str)
|
272
|
-
new(Base64.strict_decode64(base64str))
|
273
|
-
end
|
274
268
|
end
|
275
269
|
end
|
276
270
|
end
|
277
271
|
|
278
|
-
String.
|
272
|
+
String.prepend(Workato::Extension::String)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Workato
|
@@ -24,6 +25,7 @@ module Workato
|
|
24
25
|
File.binread(content_path)
|
25
26
|
ensure
|
26
27
|
File.unlink(content_path) if content_path.exist?
|
28
|
+
@content_path = ''
|
27
29
|
end
|
28
30
|
|
29
31
|
def deserialize(string)
|
@@ -32,6 +34,9 @@ module Workato
|
|
32
34
|
end
|
33
35
|
File.write(@content_path, string)
|
34
36
|
::YAML.safe_load(read).presence || {}
|
37
|
+
ensure
|
38
|
+
File.unlink(content_path) if content_path.exist?
|
39
|
+
@content_path = ''
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
data/lib/workato/web/app.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workato-connector-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Abolmasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.3.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: i18n
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.5
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.5
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: jwt
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - '='
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
145
|
+
version: 2.16.0
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - '='
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.
|
152
|
+
version: 2.16.0
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: net-http-digest_auth
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,20 +234,48 @@ dependencies:
|
|
220
234
|
- - "~>"
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '1.0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: ruby_rncryptor
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '3.0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '3.0'
|
223
251
|
- !ruby/object:Gem::Dependency
|
224
252
|
name: rubyzip
|
225
253
|
requirement: !ruby/object:Gem::Requirement
|
226
254
|
requirements:
|
227
255
|
- - "~>"
|
228
256
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
257
|
+
version: '2.3'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '2.3'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: sorbet-runtime
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0.5'
|
230
272
|
type: :runtime
|
231
273
|
prerelease: false
|
232
274
|
version_requirements: !ruby/object:Gem::Requirement
|
233
275
|
requirements:
|
234
276
|
- - "~>"
|
235
277
|
- !ruby/object:Gem::Version
|
236
|
-
version: '
|
278
|
+
version: '0.5'
|
237
279
|
- !ruby/object:Gem::Dependency
|
238
280
|
name: thor
|
239
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,6 +346,20 @@ dependencies:
|
|
304
346
|
- - "~>"
|
305
347
|
- !ruby/object:Gem::Version
|
306
348
|
version: '3.0'
|
349
|
+
- !ruby/object:Gem::Dependency
|
350
|
+
name: sorbet
|
351
|
+
requirement: !ruby/object:Gem::Requirement
|
352
|
+
requirements:
|
353
|
+
- - "~>"
|
354
|
+
- !ruby/object:Gem::Version
|
355
|
+
version: '0.5'
|
356
|
+
type: :development
|
357
|
+
prerelease: false
|
358
|
+
version_requirements: !ruby/object:Gem::Requirement
|
359
|
+
requirements:
|
360
|
+
- - "~>"
|
361
|
+
- !ruby/object:Gem::Version
|
362
|
+
version: '0.5'
|
307
363
|
- !ruby/object:Gem::Dependency
|
308
364
|
name: stub_server
|
309
365
|
requirement: !ruby/object:Gem::Requirement
|
@@ -469,7 +525,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
469
525
|
- !ruby/object:Gem::Version
|
470
526
|
version: '0'
|
471
527
|
requirements: []
|
472
|
-
|
528
|
+
rubyforge_project:
|
529
|
+
rubygems_version: 2.6.14.4
|
473
530
|
signing_key:
|
474
531
|
specification_version: 4
|
475
532
|
summary: Gem for running adapter's code outside Workato infrastructure
|