workato-connector-sdk 1.2.0 → 1.3.1
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.
- checksums.yaml +4 -4
- data/.yardopts +8 -0
- data/README.md +2 -6
- data/VERSION +1 -0
- data/lib/workato/cli/edit_command.rb +3 -1
- data/lib/workato/cli/exec_command.rb +76 -10
- data/lib/workato/cli/generate_command.rb +3 -2
- data/lib/workato/cli/main.rb +18 -10
- data/lib/workato/cli/oauth2_command.rb +4 -4
- data/lib/workato/cli/push_command.rb +23 -7
- data/lib/workato/cli/schema_command.rb +20 -6
- data/lib/workato/connector/sdk/account_properties.rb +3 -3
- data/lib/workato/connector/sdk/action.rb +20 -70
- data/lib/workato/connector/sdk/block_invocation_refinements.rb +4 -11
- data/lib/workato/connector/sdk/connection.rb +44 -21
- data/lib/workato/connector/sdk/connector.rb +73 -76
- data/lib/workato/connector/sdk/core.rb +62 -0
- data/lib/workato/connector/sdk/dsl/aws.rb +13 -3
- data/lib/workato/connector/sdk/dsl/call.rb +1 -1
- data/lib/workato/connector/sdk/dsl/csv_package.rb +133 -0
- data/lib/workato/connector/sdk/dsl/error.rb +2 -0
- data/lib/workato/connector/sdk/dsl/execution_context.rb +3 -0
- data/lib/workato/connector/sdk/dsl/http.rb +7 -2
- data/lib/workato/connector/sdk/dsl/reinvoke_after.rb +84 -0
- data/lib/workato/connector/sdk/dsl/stream_package.rb +59 -0
- data/lib/workato/connector/sdk/dsl/time.rb +0 -14
- data/lib/workato/connector/sdk/dsl/workato_package.rb +152 -0
- data/lib/workato/connector/sdk/dsl.rb +65 -10
- data/lib/workato/connector/sdk/errors.rb +28 -11
- data/lib/workato/connector/sdk/object_definitions.rb +59 -18
- data/lib/workato/connector/sdk/operation.rb +10 -3
- data/lib/workato/connector/sdk/request.rb +67 -26
- data/lib/workato/connector/sdk/schema/field/convertors.rb +2 -2
- data/lib/workato/connector/sdk/schema.rb +10 -7
- data/lib/workato/connector/sdk/settings.rb +13 -2
- data/lib/workato/connector/sdk/stream.rb +262 -0
- data/lib/workato/connector/sdk/streams.rb +72 -0
- data/lib/workato/connector/sdk/summarize.rb +4 -2
- data/lib/workato/connector/sdk/trigger.rb +14 -7
- data/lib/workato/connector/sdk/version.rb +1 -1
- data/lib/workato/connector/sdk.rb +20 -46
- data/lib/workato/extension/array.rb +2 -0
- data/lib/workato/extension/case_sensitive_headers.rb +0 -1
- data/lib/workato/extension/content_encoding_decoder.rb +2 -0
- data/lib/workato/extension/currency/countries.rb +79 -0
- data/lib/workato/extension/currency/countries.yml +18433 -0
- data/lib/workato/extension/currency/currencies.rb +55 -0
- data/lib/workato/extension/currency/currencies.yml +479 -0
- data/lib/workato/extension/currency.rb +73 -5
- data/lib/workato/extension/enumerable.rb +2 -2
- data/lib/workato/extension/metadata_fix_wrap_kw_args.rb +11 -0
- data/lib/workato/extension/string.rb +23 -111
- data/lib/workato/testing/vcr_encrypted_cassette_serializer.rb +2 -0
- data/lib/workato/testing/vcr_multipart_body_matcher.rb +1 -0
- data/lib/workato/types/binary.rb +99 -0
- data/lib/workato/types/unicode_string.rb +62 -0
- metadata +34 -62
- data/lib/workato/connector/sdk/dsl/csv.rb +0 -125
- data/lib/workato/connector/sdk/dsl/workato_code_lib.rb +0 -167
- data/lib/workato/connector/sdk/schema/type/unicode_string.rb +0 -23
@@ -4,7 +4,13 @@
|
|
4
4
|
module Workato
|
5
5
|
module Connector
|
6
6
|
module Sdk
|
7
|
-
|
7
|
+
Error = Class.new(StandardError)
|
8
|
+
|
9
|
+
DetectOnUnauthorizedRequestError = Class.new(Error)
|
10
|
+
|
11
|
+
RuntimeError = Class.new(Error)
|
12
|
+
|
13
|
+
InvalidDefinitionError = Class.new(Error)
|
8
14
|
|
9
15
|
class UnexpectedMethodDefinitionError < InvalidDefinitionError
|
10
16
|
attr_reader :name
|
@@ -28,8 +34,6 @@ module Workato
|
|
28
34
|
|
29
35
|
InvalidSchemaError = Class.new(InvalidDefinitionError)
|
30
36
|
|
31
|
-
CustomRequestError = Class.new(StandardError)
|
32
|
-
|
33
37
|
InvalidMultiAuthDefinition = Class.new(InvalidDefinitionError)
|
34
38
|
|
35
39
|
class UnresolvedMultiAuthOptionError < InvalidMultiAuthDefinition
|
@@ -41,9 +45,7 @@ module Workato
|
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
class UnresolvedObjectDefinitionError < StandardError
|
48
|
+
class UnresolvedObjectDefinitionError < InvalidDefinitionError
|
47
49
|
attr_reader :name
|
48
50
|
|
49
51
|
def initialize(name)
|
@@ -52,7 +54,7 @@ module Workato
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
class CircleReferenceObjectDefinitionError <
|
57
|
+
class CircleReferenceObjectDefinitionError < InvalidDefinitionError
|
56
58
|
attr_reader :name
|
57
59
|
|
58
60
|
def initialize(name, backtrace = [])
|
@@ -62,7 +64,11 @@ module Workato
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
|
67
|
+
RequestError = Class.new(RuntimeError)
|
68
|
+
|
69
|
+
RequestTimeoutError = Class.new(RequestError)
|
70
|
+
|
71
|
+
class RequestFailedError < RequestError
|
66
72
|
attr_reader :method
|
67
73
|
attr_reader :code
|
68
74
|
attr_reader :response
|
@@ -81,7 +87,7 @@ module Workato
|
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
84
|
-
class MissingRequiredInput <
|
90
|
+
class MissingRequiredInput < RuntimeError
|
85
91
|
def initialize(label, toggle_label)
|
86
92
|
message = if toggle_label && label != toggle_label
|
87
93
|
"Either '#{label}' or '#{toggle_label}' must be present"
|
@@ -92,9 +98,9 @@ module Workato
|
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
95
|
-
RequestTLSCertificateFormatError = Class.new(
|
101
|
+
RequestTLSCertificateFormatError = Class.new(RequestError)
|
96
102
|
|
97
|
-
RequestPayloadFormatError = Class.new(
|
103
|
+
RequestPayloadFormatError = Class.new(RequestError)
|
98
104
|
|
99
105
|
JSONRequestFormatError = Class.new(RequestPayloadFormatError)
|
100
106
|
|
@@ -109,6 +115,17 @@ module Workato
|
|
109
115
|
MultipartFormRequestFormatError = Class.new(RequestPayloadFormatError)
|
110
116
|
|
111
117
|
RAWResponseFormatError = Class.new(RequestPayloadFormatError)
|
118
|
+
|
119
|
+
class UndefinedStdLibMethodError < RuntimeError
|
120
|
+
attr_reader :name
|
121
|
+
attr_reader :package
|
122
|
+
|
123
|
+
def initialize(name, package)
|
124
|
+
@name = name
|
125
|
+
@package = package
|
126
|
+
super("Undefined method '#{name}' for \"#{package}\" namespace")
|
127
|
+
end
|
128
|
+
end
|
112
129
|
end
|
113
130
|
end
|
114
131
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require_relative './block_invocation_refinements'
|
@@ -6,31 +6,45 @@ require_relative './block_invocation_refinements'
|
|
6
6
|
module Workato
|
7
7
|
module Connector
|
8
8
|
module Sdk
|
9
|
+
module SorbetTypes
|
10
|
+
ObjectDefinitionOutput = T.type_alias { T::Array[HashWithIndifferentAccess] }
|
11
|
+
end
|
12
|
+
|
9
13
|
class ObjectDefinitions
|
14
|
+
extend T::Sig
|
15
|
+
|
10
16
|
using BlockInvocationRefinements
|
11
17
|
|
18
|
+
sig do
|
19
|
+
params(
|
20
|
+
object_definitions: SorbetTypes::SourceHash,
|
21
|
+
connection: Connection,
|
22
|
+
methods: SorbetTypes::SourceHash
|
23
|
+
).void
|
24
|
+
end
|
12
25
|
def initialize(object_definitions:, connection:, methods:)
|
13
26
|
@object_definitions_source = object_definitions
|
14
27
|
@methods_source = methods
|
15
28
|
@connection = connection
|
16
|
-
|
29
|
+
@object_definitions = T.let({}, T::Hash[T.any(String, Symbol), ObjectDefinition])
|
30
|
+
define_object_definition_methods
|
17
31
|
end
|
18
32
|
|
33
|
+
sig do
|
34
|
+
params(
|
35
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
36
|
+
config_fields: SorbetTypes::OperationInputHash
|
37
|
+
).returns(HashWithIndifferentAccess)
|
38
|
+
end
|
19
39
|
def lazy(settings = nil, config_fields = {})
|
20
40
|
DupHashWithIndifferentAccess.new do |object_definitions, name|
|
21
41
|
fields_proc = object_definitions_source.dig(name, :fields)
|
22
42
|
raise Workato::Connector::Sdk::UnresolvedObjectDefinitionError, name unless fields_proc
|
23
43
|
|
24
44
|
begin
|
25
|
-
object_definitions[name] =
|
26
|
-
|
27
|
-
|
28
|
-
instance_exec(connection, input, object_definitions, &fields_proc)
|
29
|
-
end
|
30
|
-
},
|
31
|
-
methods: methods_source,
|
32
|
-
connection: connection
|
33
|
-
).execute(settings, config_fields)
|
45
|
+
object_definitions[name] = create_operation.execute(settings, config_fields) do |connection, input|
|
46
|
+
instance_exec(connection, input, object_definitions, &fields_proc)
|
47
|
+
end
|
34
48
|
rescue SystemStackError => e
|
35
49
|
raise Workato::Connector::Sdk::CircleReferenceObjectDefinitionError.new(name, e.backtrace)
|
36
50
|
end
|
@@ -39,40 +53,67 @@ module Workato
|
|
39
53
|
|
40
54
|
private
|
41
55
|
|
56
|
+
sig { returns(SorbetTypes::SourceHash) }
|
42
57
|
attr_reader :methods_source
|
58
|
+
|
59
|
+
sig { returns(Connection) }
|
43
60
|
attr_reader :connection
|
44
|
-
|
61
|
+
|
62
|
+
sig { returns(SorbetTypes::SourceHash) }
|
45
63
|
attr_reader :object_definitions_source
|
46
64
|
|
47
|
-
|
48
|
-
|
65
|
+
sig { void }
|
66
|
+
def define_object_definition_methods
|
67
|
+
object_definitions_source.each do |(object, _definition)|
|
49
68
|
define_singleton_method(object) do
|
50
|
-
@object_definitions ||= {}
|
51
69
|
@object_definitions[object] ||= ObjectDefinition.new(name: object, object_definitions: self)
|
52
70
|
end
|
53
71
|
end
|
54
72
|
end
|
55
73
|
|
74
|
+
sig { returns(Operation) }
|
75
|
+
def create_operation
|
76
|
+
Operation.new(methods: methods_source, connection: connection)
|
77
|
+
end
|
78
|
+
|
56
79
|
class ObjectDefinition
|
80
|
+
extend T::Sig
|
81
|
+
|
82
|
+
sig { params(name: T.any(String, Symbol), object_definitions: ObjectDefinitions).void }
|
57
83
|
def initialize(name:, object_definitions:)
|
58
|
-
@object_definitions = object_definitions
|
59
84
|
@name = name
|
85
|
+
@object_definitions = object_definitions
|
60
86
|
end
|
61
87
|
|
88
|
+
sig do
|
89
|
+
params(
|
90
|
+
settings: T.nilable(SorbetTypes::SettingsHash),
|
91
|
+
config_fields: SorbetTypes::OperationInputHash
|
92
|
+
).returns(SorbetTypes::ObjectDefinitionOutput)
|
93
|
+
end
|
62
94
|
def fields(settings = nil, config_fields = {})
|
63
95
|
object_definitions_lazy_hash = @object_definitions.lazy(settings, config_fields)
|
64
96
|
object_definitions_lazy_hash[@name]
|
65
97
|
end
|
66
98
|
end
|
67
99
|
|
100
|
+
private_constant :ObjectDefinition
|
101
|
+
|
68
102
|
class DupHashWithIndifferentAccess < HashWithIndifferentAccess
|
103
|
+
extend T::Sig
|
104
|
+
extend T::Generic
|
105
|
+
|
106
|
+
K = type_member { { fixed: T.any(String, Symbol) } }
|
107
|
+
V = type_member { { fixed: T.untyped } }
|
108
|
+
Elem = type_member { { fixed: T.untyped } }
|
109
|
+
|
110
|
+
sig { params(name: K).returns(V) }
|
69
111
|
def [](name)
|
70
112
|
super.deep_dup
|
71
113
|
end
|
72
114
|
end
|
73
115
|
|
74
|
-
private_constant
|
75
|
-
private_constant 'DupHashWithIndifferentAccess'
|
116
|
+
private_constant :DupHashWithIndifferentAccess
|
76
117
|
end
|
77
118
|
end
|
78
119
|
end
|
@@ -44,6 +44,7 @@ module Workato
|
|
44
44
|
extend T::Sig
|
45
45
|
|
46
46
|
include Dsl::Global
|
47
|
+
include Dsl::AWS
|
47
48
|
include Dsl::HTTP
|
48
49
|
include Dsl::Call
|
49
50
|
include Dsl::Error
|
@@ -51,18 +52,24 @@ module Workato
|
|
51
52
|
|
52
53
|
using BlockInvocationRefinements
|
53
54
|
|
55
|
+
sig { override.returns(Streams) }
|
56
|
+
attr_reader :streams
|
57
|
+
|
54
58
|
sig do
|
55
59
|
params(
|
56
60
|
operation: SorbetTypes::SourceHash,
|
57
61
|
methods: SorbetTypes::SourceHash,
|
58
62
|
connection: Connection,
|
63
|
+
streams: Streams,
|
59
64
|
object_definitions: T.nilable(ObjectDefinitions)
|
60
65
|
).void
|
61
66
|
end
|
62
|
-
def initialize(operation: {}, methods: {}, connection: Connection.new,
|
67
|
+
def initialize(operation: {}, methods: {}, connection: Connection.new, streams: ProhibitedStreams.new,
|
68
|
+
object_definitions: nil)
|
63
69
|
@operation = T.let(HashWithIndifferentAccess.wrap(operation), HashWithIndifferentAccess)
|
64
70
|
@_methods = T.let(HashWithIndifferentAccess.wrap(methods), HashWithIndifferentAccess)
|
65
71
|
@connection = T.let(connection, Connection)
|
72
|
+
@streams = T.let(streams, Streams)
|
66
73
|
@object_definitions = T.let(object_definitions, T.nilable(ObjectDefinitions))
|
67
74
|
end
|
68
75
|
|
@@ -218,7 +225,7 @@ module Workato
|
|
218
225
|
def resolve_request(request_or_result)
|
219
226
|
case request_or_result
|
220
227
|
when Request
|
221
|
-
resolve_request(request_or_result.
|
228
|
+
resolve_request(request_or_result.response!)
|
222
229
|
when ::Array
|
223
230
|
request_or_result.each_with_index.inject(request_or_result) do |acc, (item, index)|
|
224
231
|
response_item = resolve_request(item)
|
@@ -262,7 +269,7 @@ module Workato
|
|
262
269
|
sig { returns(HashWithIndifferentAccess) }
|
263
270
|
attr_reader :operation
|
264
271
|
|
265
|
-
sig { returns(Connection) }
|
272
|
+
sig { override.returns(Connection) }
|
266
273
|
attr_reader :connection
|
267
274
|
end
|
268
275
|
end
|
@@ -7,6 +7,7 @@ require 'json'
|
|
7
7
|
require 'gyoku'
|
8
8
|
require 'net/http'
|
9
9
|
require 'net/http/digest_auth'
|
10
|
+
require 'active_support/json'
|
10
11
|
|
11
12
|
require 'workato/utilities/encoding'
|
12
13
|
require 'workato/utilities/xml'
|
@@ -37,18 +38,20 @@ module Workato
|
|
37
38
|
@callstack_before_request = Array.wrap(Kernel.caller)
|
38
39
|
end
|
39
40
|
|
40
|
-
def method_missing(
|
41
|
-
|
41
|
+
def method_missing(...)
|
42
|
+
response!.send(...)
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def response!
|
45
46
|
__getobj__ || __setobj__(response)
|
47
|
+
rescue RestClient::Exceptions::Timeout => e
|
48
|
+
Kernel.raise RequestTimeoutError, e
|
46
49
|
rescue RestClient::Exception => e
|
47
50
|
if after_error_response_matches?(e)
|
48
51
|
return apply_after_error_response(e)
|
49
52
|
end
|
50
53
|
|
51
|
-
Kernel.raise
|
54
|
+
Kernel.raise RequestFailedError.new(
|
52
55
|
response: e.response,
|
53
56
|
message: e.message,
|
54
57
|
method: current_verb,
|
@@ -250,8 +253,8 @@ module Workato
|
|
250
253
|
::Kernel.puts(*args)
|
251
254
|
end
|
252
255
|
|
253
|
-
def try(
|
254
|
-
|
256
|
+
def try(...)
|
257
|
+
response!.try(...)
|
255
258
|
end
|
256
259
|
|
257
260
|
private
|
@@ -275,9 +278,9 @@ module Workato
|
|
275
278
|
request = RestClientRequest.new(rest_request_params)
|
276
279
|
response = execute_request(request)
|
277
280
|
end
|
278
|
-
|
281
|
+
detect_auth_error!(response.body)
|
279
282
|
parsed_response = @parse_response.call(response)
|
280
|
-
|
283
|
+
detect_auth_error!(parsed_response)
|
281
284
|
apply_after_response(response.code, parsed_response, response.headers)
|
282
285
|
end
|
283
286
|
end
|
@@ -322,7 +325,7 @@ module Workato
|
|
322
325
|
|
323
326
|
def build_url
|
324
327
|
uri = if @base_uri
|
325
|
-
|
328
|
+
merge_uris(@base_uri, @uri)
|
326
329
|
else
|
327
330
|
URI.parse(@uri)
|
328
331
|
end
|
@@ -347,9 +350,13 @@ module Workato
|
|
347
350
|
uri.to_s
|
348
351
|
end
|
349
352
|
|
353
|
+
def merge_uris(uri1, uri2)
|
354
|
+
(uri1.is_a?(::String) ? URI.parse(uri1) : uri1).merge(uri2)
|
355
|
+
end
|
356
|
+
|
350
357
|
def build_headers
|
351
358
|
headers = @headers
|
352
|
-
if @content_type_header.present? && headers.keys.none? { |key| /^content[
|
359
|
+
if @content_type_header.present? && headers.keys.none? { |key| /^content[-_]type$/i =~ key }
|
353
360
|
headers[:content_type] = @content_type_header
|
354
361
|
end
|
355
362
|
if @accept_header && headers.keys.none? { |key| /^accept$/i =~ key }
|
@@ -358,13 +365,13 @@ module Workato
|
|
358
365
|
headers.compact
|
359
366
|
end
|
360
367
|
|
361
|
-
def
|
368
|
+
def detect_auth_error!(response)
|
362
369
|
return unless authorized?
|
363
370
|
|
364
371
|
error_patterns = connection.authorization.detect_on
|
365
372
|
return unless error_patterns.any? { |pattern| pattern === response rescue false }
|
366
373
|
|
367
|
-
Kernel.raise(
|
374
|
+
Kernel.raise(DetectOnUnauthorizedRequestError, response.to_s)
|
368
375
|
end
|
369
376
|
|
370
377
|
def after_error_response_matches?(exception)
|
@@ -399,8 +406,8 @@ module Workato
|
|
399
406
|
within_action_context(code, parsed_response, encoded_headers, &@after_response)
|
400
407
|
end
|
401
408
|
|
402
|
-
def within_action_context(
|
403
|
-
(@action || self).instance_exec(
|
409
|
+
def within_action_context(...)
|
410
|
+
(@action || self).instance_exec(...)
|
404
411
|
end
|
405
412
|
|
406
413
|
sig { returns(T::Boolean) }
|
@@ -418,14 +425,14 @@ module Workato
|
|
418
425
|
begin
|
419
426
|
settings = connection.settings
|
420
427
|
if connection.authorization.oauth2?
|
421
|
-
|
428
|
+
apply_oauth2(settings, settings[:access_token], @auth_type, &apply)
|
422
429
|
else
|
423
|
-
|
430
|
+
apply_custom_auth(settings, @auth_type, &apply)
|
424
431
|
end
|
425
432
|
yield
|
426
|
-
rescue RestClient::Exception,
|
433
|
+
rescue RestClient::Exception, DetectOnUnauthorizedRequestError => e
|
427
434
|
Kernel.raise e unless first
|
428
|
-
Kernel.raise e unless refresh_authorization!(e.try(:http_code), e.try(:http_body), e.message)
|
435
|
+
Kernel.raise e unless refresh_authorization!(settings, e.try(:http_code), e.try(:http_body), e.message)
|
429
436
|
|
430
437
|
first = false
|
431
438
|
retry
|
@@ -434,16 +441,49 @@ module Workato
|
|
434
441
|
|
435
442
|
sig do
|
436
443
|
params(
|
444
|
+
settings: HashWithIndifferentAccess,
|
445
|
+
access_token: T.untyped,
|
446
|
+
auth_type: T.untyped,
|
447
|
+
apply_proc: T.proc.params(
|
448
|
+
settings: HashWithIndifferentAccess,
|
449
|
+
access_token: T.untyped,
|
450
|
+
auth_type: T.untyped
|
451
|
+
).void
|
452
|
+
).void
|
453
|
+
end
|
454
|
+
def apply_oauth2(settings, access_token, auth_type, &apply_proc)
|
455
|
+
instance_exec(settings, access_token, auth_type, &apply_proc)
|
456
|
+
end
|
457
|
+
|
458
|
+
sig do
|
459
|
+
params(
|
460
|
+
settings: HashWithIndifferentAccess,
|
461
|
+
auth_type: T.untyped,
|
462
|
+
apply_proc: T.proc.params(
|
463
|
+
settings: HashWithIndifferentAccess,
|
464
|
+
auth_type: T.untyped
|
465
|
+
).void
|
466
|
+
).void
|
467
|
+
end
|
468
|
+
def apply_custom_auth(settings, auth_type, &apply_proc)
|
469
|
+
instance_exec(settings, auth_type, &apply_proc)
|
470
|
+
end
|
471
|
+
|
472
|
+
sig do
|
473
|
+
params(
|
474
|
+
settings_before: HashWithIndifferentAccess,
|
437
475
|
http_code: T.nilable(Integer),
|
438
476
|
http_body: T.nilable(String),
|
439
477
|
exception: T.nilable(String)
|
440
478
|
).returns(T::Boolean)
|
441
479
|
end
|
442
|
-
def refresh_authorization!(http_code, http_body, exception)
|
480
|
+
def refresh_authorization!(settings_before, http_code, http_body, exception)
|
443
481
|
return false unless connection.authorization.refresh?(http_code, http_body, exception)
|
444
482
|
|
445
|
-
connection.update_settings!("Refresh token triggered on response \"#{exception}\"") do
|
446
|
-
connection.
|
483
|
+
connection.update_settings!("Refresh token triggered on response \"#{exception}\"", settings_before) do
|
484
|
+
next connection.settings unless connection.settings == settings_before
|
485
|
+
|
486
|
+
connection.authorization.refresh!(settings_before)
|
447
487
|
end
|
448
488
|
end
|
449
489
|
|
@@ -454,11 +494,9 @@ module Workato
|
|
454
494
|
|
455
495
|
def lambda_with_error_wrap(error_type, &block)
|
456
496
|
Kernel.lambda do |payload|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
Kernel.raise error_type.new(e)
|
461
|
-
end
|
497
|
+
block.call(payload)
|
498
|
+
rescue StandardError => e
|
499
|
+
Kernel.raise error_type.new(e)
|
462
500
|
end
|
463
501
|
end
|
464
502
|
|
@@ -475,6 +513,8 @@ module Workato
|
|
475
513
|
attr_reader :original_filename
|
476
514
|
end
|
477
515
|
|
516
|
+
private_constant :Part
|
517
|
+
|
478
518
|
class RestClientRequest < ::RestClient::Request
|
479
519
|
def initialize(args)
|
480
520
|
super
|
@@ -502,6 +542,7 @@ module Workato
|
|
502
542
|
net
|
503
543
|
end
|
504
544
|
end
|
545
|
+
|
505
546
|
private_constant :RestClientRequest
|
506
547
|
end
|
507
548
|
end
|
@@ -26,7 +26,7 @@ module Workato
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def integer_conversion(value)
|
29
|
-
value.try(:is_number?) && value.to_i || value
|
29
|
+
(value.try(:is_number?) && value.to_i) || value
|
30
30
|
end
|
31
31
|
|
32
32
|
def boolean_conversion(value)
|
@@ -34,7 +34,7 @@ module Workato
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def float_conversion(value)
|
37
|
-
value.try(:is_number?) && value.to_f || value
|
37
|
+
(value.try(:is_number?) && value.to_f) || value
|
38
38
|
end
|
39
39
|
|
40
40
|
def item_array_wrap(items)
|
@@ -101,17 +101,17 @@ module Workato
|
|
101
101
|
return Type::Time.from_date_time(value)
|
102
102
|
when ::Date
|
103
103
|
return value.to_date
|
104
|
-
when ::Numeric, ::TrueClass, ::FalseClass, Workato::
|
105
|
-
::Array, ::Hash
|
104
|
+
when ::Numeric, ::TrueClass, ::FalseClass, Workato::Types::Binary, Workato::Types::UnicodeString,
|
105
|
+
::Array, ::Hash, Stream::Proxy
|
106
106
|
return value
|
107
107
|
when Extension::Array::ArrayWhere
|
108
108
|
return value.to_a
|
109
109
|
when ::String
|
110
110
|
if value.encoding == Encoding::ASCII_8BIT
|
111
|
-
return Workato::
|
111
|
+
return Workato::Types::Binary.new(value)
|
112
112
|
end
|
113
113
|
|
114
|
-
return
|
114
|
+
return Workato::Types::UnicodeString.new(value)
|
115
115
|
else
|
116
116
|
if value.respond_to?(:to_time)
|
117
117
|
return Type::Time.from_time(value.to_time)
|
@@ -119,7 +119,7 @@ module Workato
|
|
119
119
|
|
120
120
|
if value.respond_to?(:read) && value.respond_to?(:rewind)
|
121
121
|
value.rewind
|
122
|
-
return Workato::
|
122
|
+
return Workato::Types::Binary.new(value.read.force_encoding(Encoding::ASCII_8BIT))
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -127,6 +127,8 @@ module Workato
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
+
private_constant :Schema
|
131
|
+
|
130
132
|
class Fields < ::Array
|
131
133
|
def initialize(fields)
|
132
134
|
::Array.wrap(fields).each do |field|
|
@@ -178,7 +180,9 @@ module Workato
|
|
178
180
|
|
179
181
|
def clean_values(field)
|
180
182
|
field.transform_values! do |value|
|
181
|
-
value
|
183
|
+
next value if value.is_a?(FalseClass)
|
184
|
+
|
185
|
+
value.presence && ((value.is_a?(::Symbol) && value.to_s) || value)
|
182
186
|
end
|
183
187
|
field.compact!
|
184
188
|
field
|
@@ -230,4 +234,3 @@ require_relative './schema/field/object'
|
|
230
234
|
require_relative './schema/field/string'
|
231
235
|
|
232
236
|
require_relative './schema/type/time'
|
233
|
-
require_relative './schema/type/unicode_string'
|
@@ -82,7 +82,7 @@ module Workato
|
|
82
82
|
|
83
83
|
def read_plain_file
|
84
84
|
all_settings = File.open(path) do |f|
|
85
|
-
YAML.safe_load(f.read, [::Symbol]).to_hash.with_indifferent_access
|
85
|
+
YAML.safe_load(f.read, permitted_classes: [::Symbol]).to_hash.with_indifferent_access
|
86
86
|
end
|
87
87
|
|
88
88
|
(name ? all_settings.fetch(name) : all_settings) || {}
|
@@ -123,7 +123,7 @@ module Workato
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def encrypted_configuration
|
126
|
-
@encrypted_configuration ||=
|
126
|
+
@encrypted_configuration ||= FixedEncryptedConfiguration.new(
|
127
127
|
config_path: path,
|
128
128
|
key_path: key_path || DEFAULT_MASTER_KEY_PATH,
|
129
129
|
env_key: DEFAULT_MASTER_KEY_ENV,
|
@@ -135,6 +135,17 @@ module Workato
|
|
135
135
|
YAML.dump(settings.to_hash)
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
class FixedEncryptedConfiguration < ActiveSupport::EncryptedConfiguration
|
140
|
+
private
|
141
|
+
|
142
|
+
def handle_missing_key
|
143
|
+
# Original methods incorectly passes constructor params
|
144
|
+
raise MissingKeyError.new(key_path: key_path, env_key: env_key) if raise_if_missing_key
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
private_constant :FixedEncryptedConfiguration
|
138
149
|
end
|
139
150
|
end
|
140
151
|
end
|