workato-connector-sdk 0.5.0 → 1.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.
- checksums.yaml +4 -4
- data/README.md +44 -24
- data/lib/workato/cli/exec_command.rb +1 -1
- data/lib/workato/cli/generate_command.rb +3 -3
- data/lib/workato/cli/main.rb +3 -2
- data/lib/workato/connector/sdk/trigger.rb +32 -12
- data/lib/workato/connector/sdk/version.rb +1 -1
- data/lib/workato/extension/string.rb +6 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 922f90ef16e3eb7117c0d5ef9c1c4fe108936a1d9a2a8bb84cc366d401df8d08
|
4
|
+
data.tar.gz: 8d276d47055754f84b61ccb23d5f38eaad7bef21e233eabd298bb35a946fe3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65094b1e01fad336534f136316c7fd19400b9ef053122ba2052cbbd78bc76c5e7f92b53e05e0b5bd1be9c66fc9f96c1346a2bc7802321ec19819cff4157b393b
|
7
|
+
data.tar.gz: 0cf175c8771e6fad96e26865e9306edc936c8f986c3889fc2b98737c24c96eae9ab13720923b82dc8eaf9f860431a888d74c90a746952c5739150216ce60479b
|
data/README.md
CHANGED
@@ -265,27 +265,28 @@ Usage:
|
|
265
265
|
workato exec <PATH>
|
266
266
|
|
267
267
|
Options:
|
268
|
-
-c, [--connector=CONNECTOR]
|
269
|
-
-s, [--settings=SETTINGS]
|
270
|
-
-n, [--connection=CONNECTION]
|
271
|
-
-k, [--key=KEY]
|
272
|
-
-i, [--input=INPUT]
|
273
|
-
[--closure=CLOSURE]
|
274
|
-
[--continue=CONTINUE]
|
275
|
-
-a, [--args=ARGS]
|
276
|
-
[--extended-input-schema=EXTENDED_INPUT_SCHEMA]
|
277
|
-
[--extended-output-schema=EXTENDED_OUTPUT_SCHEMA]
|
278
|
-
[--config-fields=CONFIG_FIELDS]
|
279
|
-
-w, [--webhook-payload=WEBHOOK_PAYLOAD]
|
280
|
-
[--webhook-params=WEBHOOK_PARAMS]
|
281
|
-
[--webhook-headers=WEBHOOK_HEADERS]
|
282
|
-
[--webhook-
|
283
|
-
|
284
|
-
|
285
|
-
[--
|
286
|
-
[--
|
287
|
-
[--
|
288
|
-
[--
|
268
|
+
-c, [--connector=CONNECTOR] # Path to connector source code
|
269
|
+
-s, [--settings=SETTINGS] # Path to plain or encrypted file with connection configs, passwords, tokens, secrets etc
|
270
|
+
-n, [--connection=CONNECTION] # Connection name if settings file contains multiple settings
|
271
|
+
-k, [--key=KEY] # Path to file with encrypt/decrypt key. NOTE: key from WORKATO_CONNECTOR_MASTER_KEY has higher priority
|
272
|
+
-i, [--input=INPUT] # Path to file with input JSON
|
273
|
+
[--closure=CLOSURE] # Path to file with next poll closure JSON
|
274
|
+
[--continue=CONTINUE] # Path to file with next multistep action continue closure JSON
|
275
|
+
-a, [--args=ARGS] # Path to file with method arguments JSON
|
276
|
+
[--extended-input-schema=EXTENDED_INPUT_SCHEMA] # Path to file with extended input schema definition JSON
|
277
|
+
[--extended-output-schema=EXTENDED_OUTPUT_SCHEMA] # Path to file with extended output schema definition JSON
|
278
|
+
[--config-fields=CONFIG_FIELDS] # Path to file with config fields JSON
|
279
|
+
-w, [--webhook-payload=WEBHOOK_PAYLOAD] # Path to file with webhook payload JSON
|
280
|
+
[--webhook-params=WEBHOOK_PARAMS] # Path to file with webhook params JSON
|
281
|
+
[--webhook-headers=WEBHOOK_HEADERS] # Path to file with webhook headers JSON
|
282
|
+
[--webhook-subscribe-output=WEBHOOK_SUBSCRIBE_OUTPUT] # Path to file with webhook subscribe output JSON
|
283
|
+
[--webhook-url=WEBHOOK_URL] # Webhook URL for automatic webhook subscription
|
284
|
+
-o, [--output=OUTPUT] # Write output to JSON file
|
285
|
+
[--oauth2-code=OAUTH2_CODE] # OAuth2 code exchange to tokens pair
|
286
|
+
[--redirect-url=REDIRECT_URL] # OAuth2 callback url
|
287
|
+
[--refresh-token=REFRESH_TOKEN] # OAuth2 refresh token
|
288
|
+
[--debug], [--no-debug]
|
289
|
+
[--verbose], [--no-verbose]
|
289
290
|
|
290
291
|
Description:
|
291
292
|
The 'workato exec' executes connector's lambda block at <PATH>. Lambda's parameters can be provided if needed, see options part.
|
@@ -319,7 +320,26 @@ Commands:
|
|
319
320
|
workato generate test # Generate empty test for connector
|
320
321
|
```
|
321
322
|
|
322
|
-
|
323
|
+
### 3.4.1 workato generate schema
|
324
|
+
Use command to generate Workato Schema from a sample file. Supported inputs csv, json
|
325
|
+
|
326
|
+
```
|
327
|
+
workato generate help schema
|
328
|
+
|
329
|
+
Usage:
|
330
|
+
workato generate schema
|
331
|
+
|
332
|
+
Options:
|
333
|
+
[--json=JSON] # Path to JSON sample file
|
334
|
+
[--csv=CSV] # Path to CSV sample file
|
335
|
+
[--col-sep=COL_SEP] # Use separator for CSV converter
|
336
|
+
# Default: comma
|
337
|
+
# Possible values: comma, space, tab, colon, semicolon, pipe
|
338
|
+
[--api-email=API_EMAIL] # Email for accessing Workato API or set WORKATO_API_EMAIL environment variable
|
339
|
+
[--api-token=API_TOKEN] # Token for accessing Workato API or set WORKATO_API_TOKEN environment variable
|
340
|
+
```
|
341
|
+
|
342
|
+
### 3.4.2 workato generate test
|
323
343
|
|
324
344
|
- Use `workato generate test` to generate tests based on your connector.rb file.
|
325
345
|
|
@@ -400,8 +420,8 @@ Options:
|
|
400
420
|
-l, [--logo=LOGO] # Path to connector logo: png or jpeg file
|
401
421
|
-n, [--notes=NOTES] # Release notes
|
402
422
|
-c, [--connector=CONNECTOR] # Path to connector source code
|
403
|
-
[--api-email=API_EMAIL] # Email for accessing Workato API or set WORKATO_API_EMAIL
|
404
|
-
[--api-token=API_TOKEN] # Token for accessing Workato API or set WORKATO_API_TOKEN
|
423
|
+
[--api-email=API_EMAIL] # Email for accessing Workato API or set WORKATO_API_EMAIL environment variable
|
424
|
+
[--api-token=API_TOKEN] # Token for accessing Workato API or set WORKATO_API_TOKEN environment variable
|
405
425
|
[--environment=ENVIRONMENT] # Server to push connector code to
|
406
426
|
# Default: live
|
407
427
|
# Possible values: preview, preview-eu, live, live-eu
|
@@ -50,7 +50,7 @@ module Workato
|
|
50
50
|
settings: settings,
|
51
51
|
input: from_json(options[:input]),
|
52
52
|
output: from_json(options[:input]),
|
53
|
-
webhook_subscribe_output: from_json(options[:
|
53
|
+
webhook_subscribe_output: from_json(options[:webhook_subscribe_output]).presence,
|
54
54
|
args: from_json(options[:args]).presence || [],
|
55
55
|
extended_input_schema: from_json(options[:extended_input_schema]).presence || [],
|
56
56
|
extended_output_schema: from_json(options[:extended_output_schema]).presence || [],
|
@@ -45,17 +45,17 @@ module Workato
|
|
45
45
|
method_option :csv, type: :string, desc: 'Path to CSV sample file'
|
46
46
|
method_option :col_sep,
|
47
47
|
type: :string,
|
48
|
-
desc: 'Use separator for CSV
|
48
|
+
desc: 'Use separator for CSV converter',
|
49
49
|
enum: SchemaCommand::CSV_SEPARATORS,
|
50
50
|
default: 'comma'
|
51
51
|
method_option :api_email,
|
52
52
|
type: :string,
|
53
53
|
desc: 'Email for accessing Workato API or '\
|
54
|
-
"set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV}
|
54
|
+
"set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV} environment variable"
|
55
55
|
method_option :api_token,
|
56
56
|
type: :string,
|
57
57
|
desc: 'Token for accessing Workato API or ' \
|
58
|
-
"set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV}
|
58
|
+
"set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV} environment variable"
|
59
59
|
|
60
60
|
long_desc <<~HELP
|
61
61
|
The 'workato generate schema' command generates Workato Schema from a sample file.
|
data/lib/workato/cli/main.rb
CHANGED
@@ -54,6 +54,7 @@ module Workato
|
|
54
54
|
method_option :webhook_payload, type: :string, aliases: '-w', desc: 'Path to file with webhook payload JSON'
|
55
55
|
method_option :webhook_params, type: :string, desc: 'Path to file with webhook params JSON'
|
56
56
|
method_option :webhook_headers, type: :string, desc: 'Path to file with webhook headers JSON'
|
57
|
+
method_option :webhook_subscribe_output, type: :string, desc: 'Path to file with webhook subscribe output JSON'
|
57
58
|
method_option :webhook_url, type: :string, desc: 'Webhook URL for automatic webhook subscription'
|
58
59
|
method_option :output, type: :string, aliases: '-o', desc: 'Write output to JSON file'
|
59
60
|
method_option :oauth2_code, type: :string, desc: 'OAuth2 code exchange to tokens pair'
|
@@ -126,11 +127,11 @@ module Workato
|
|
126
127
|
method_option :api_email,
|
127
128
|
type: :string,
|
128
129
|
desc: 'Email for accessing Workato API or '\
|
129
|
-
"set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV}
|
130
|
+
"set #{Workato::Connector::Sdk::WORKATO_API_EMAIL_ENV} environment variable"
|
130
131
|
method_option :api_token,
|
131
132
|
type: :string,
|
132
133
|
desc: 'Token for accessing Workato API or ' \
|
133
|
-
"set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV}
|
134
|
+
"set #{Workato::Connector::Sdk::WORKATO_API_TOKEN_ENV} environment variable"
|
134
135
|
method_option :environment,
|
135
136
|
type: :string,
|
136
137
|
enum: Workato::CLI::PushCommand::ENVIRONMENTS.keys,
|
@@ -56,8 +56,16 @@ module Workato
|
|
56
56
|
trigger[:dedup].call(input)
|
57
57
|
end
|
58
58
|
|
59
|
-
def webhook_notification(
|
60
|
-
|
59
|
+
def webhook_notification(
|
60
|
+
input = {},
|
61
|
+
payload = {},
|
62
|
+
extended_input_schema = [],
|
63
|
+
extended_output_schema = [],
|
64
|
+
headers = {},
|
65
|
+
params = {},
|
66
|
+
settings = nil,
|
67
|
+
webhook_subscribe_output = {}
|
68
|
+
)
|
61
69
|
Dsl::WithDsl.execute(
|
62
70
|
input.with_indifferent_access,
|
63
71
|
payload.with_indifferent_access,
|
@@ -65,6 +73,8 @@ module Workato
|
|
65
73
|
extended_output_schema.map(&:with_indifferent_access),
|
66
74
|
headers.with_indifferent_access,
|
67
75
|
params.with_indifferent_access,
|
76
|
+
(settings || @settings).with_indifferent_access,
|
77
|
+
webhook_subscribe_output.with_indifferent_access,
|
68
78
|
&trigger[:webhook_notification]
|
69
79
|
)
|
70
80
|
end
|
@@ -89,23 +99,33 @@ module Workato
|
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
92
|
-
def invoke(input = {}, payload = {}, headers = {}, params = {})
|
102
|
+
def invoke(input = {}, payload = {}, headers = {}, params = {}, webhook_subscribe_output = {})
|
93
103
|
extended_schema = extended_schema(nil, input)
|
94
104
|
config_schema = Schema.new(schema: config_fields_schema)
|
95
105
|
input_schema = Schema.new(schema: extended_schema[:input])
|
96
106
|
output_schema = Schema.new(schema: extended_schema[:output])
|
97
107
|
|
98
108
|
input = apply_input_schema(input, config_schema + input_schema)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
109
|
+
if webhook_notification?
|
110
|
+
webhook_notification(
|
111
|
+
input,
|
112
|
+
payload,
|
113
|
+
input_schema,
|
114
|
+
output_schema,
|
115
|
+
headers,
|
116
|
+
params,
|
117
|
+
nil,
|
118
|
+
webhook_subscribe_output
|
119
|
+
).tap do |event|
|
120
|
+
apply_output_schema(event, output_schema)
|
121
|
+
end
|
122
|
+
else
|
123
|
+
output = poll(nil, input, nil, input_schema, output_schema)
|
124
|
+
output[:events].each do |event|
|
125
|
+
apply_output_schema(event, output_schema)
|
126
|
+
end
|
127
|
+
output
|
106
128
|
end
|
107
|
-
|
108
|
-
output
|
109
129
|
end
|
110
130
|
|
111
131
|
private
|
@@ -229,6 +229,10 @@ module Workato
|
|
229
229
|
self
|
230
230
|
end
|
231
231
|
|
232
|
+
def to_json(_options = nil)
|
233
|
+
summary
|
234
|
+
end
|
235
|
+
|
232
236
|
def binary?
|
233
237
|
true
|
234
238
|
end
|
@@ -245,19 +249,12 @@ module Workato
|
|
245
249
|
as_string('utf-8')
|
246
250
|
end
|
247
251
|
|
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
252
|
def sha1
|
258
253
|
Binary.new(::Digest::SHA1.digest(self))
|
259
254
|
end
|
260
255
|
|
256
|
+
private
|
257
|
+
|
261
258
|
def summary
|
262
259
|
if length.positive?
|
263
260
|
left = "0x#{byteslice(0, SUMMARY_LENGTH).unpack1('H*')}"
|
@@ -267,10 +264,6 @@ module Workato
|
|
267
264
|
''
|
268
265
|
end
|
269
266
|
end
|
270
|
-
|
271
|
-
def self.from_base64(base64str)
|
272
|
-
new(Base64.strict_decode64(base64str))
|
273
|
-
end
|
274
267
|
end
|
275
268
|
end
|
276
269
|
end
|
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.0
|
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-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|