app_bridge 2.0.1-aarch64-linux → 2.1.1-aarch64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fd12e24427da8b6c276b64b2bd001ded74ed5221e87086b6efc98eb32cbc4dc
4
- data.tar.gz: ca3e02c42b51d003a729c77e22b1ca1a510dfcca95b6bb221366610306d34ae1
3
+ metadata.gz: 9098b4bde8b2ebd3b6ac6e08f4b3f472d2f69115b8cdea66fd7e18cc539e1b29
4
+ data.tar.gz: 69661a06a98b097ba9d81d89e7475505ff92934fe347cf165279620c2f3b314f
5
5
  SHA512:
6
- metadata.gz: 18d970e39faa4a5ae07ef72f71a364db4806edbbbb182f316cbd435d8deacea8b0b21f08f7d11a1cc071709d062ffd0cf87a59bc44708c93cdfb478e71f9095e
7
- data.tar.gz: 47115d4d44f46706a7e68ac6fdd08a7226bc37f80a2657aee301caba61f8b3887e6892312c614d407c2812060b35f2b48148b26855fa1256dbf778baaf33d92e
6
+ metadata.gz: 8504bc0da56226f56f0ccb3f239e6f3af6592e2b2c6258823bbf9d9e5260d3a6874b4382c363ec0c9a3e394396eb263506a320f52f4f90339052395e7e9d7792
7
+ data.tar.gz: d1f388683ccc526fd954106a53d742c0bf55565888079ca27848a03f29540f50da476fdd0b8efd3949fc8285b3b2247665fe8f1f874c24df078cdb8c65cb3f7d
data/.editorconfig ADDED
@@ -0,0 +1,18 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # http://editorconfig.org/
4
+
5
+ root = true
6
+
7
+ [*]
8
+ end_of_line = lf
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+ charset = utf-8
12
+ indent_style = space
13
+ indent_size = 2
14
+ curly_bracket_next_line = false
15
+ indent_brace_style = K&R
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
data/Rakefile CHANGED
@@ -3,8 +3,6 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
6
  require "rubocop/rake_task"
9
7
 
10
8
  RuboCop::RakeTask.new
@@ -22,4 +20,9 @@ end
22
20
  # Load all project specific rake tasks
23
21
  Dir.glob(File.expand_path("tasks/**/*.rake", __dir__)).each { |file| load file }
24
22
 
25
- task default: %i[fixtures compile spec rubocop]
23
+ # Set test mode environment variable for specs
24
+ RSpec::Core::RakeTask.new(:spec) do |_t|
25
+ ENV["APP_BRIDGE_TEST_MODE"] = "1"
26
+ end
27
+
28
+ task default: %i[fixtures compile rust:test spec rubocop]
@@ -1,4 +1,4 @@
1
- package standout:app@2.0.1;
1
+ package standout:app@2.1.1;
2
2
 
3
3
  interface types {
4
4
  // The trigger-store is a string that is used to store data between trigger
@@ -10,10 +10,10 @@ interface types {
10
10
  // need to add more data to the store.
11
11
  type trigger-store = string;
12
12
 
13
- record account {
13
+ record connection {
14
14
  id: string,
15
15
  name: string,
16
- // The account data is a JSON object serialized into a string. The JSON root
16
+ // The connection data is a JSON object serialized into a string. The JSON root
17
17
  // will always be an object.
18
18
  serialized-data: string,
19
19
  }
@@ -23,12 +23,31 @@ interface types {
23
23
  // invoked.
24
24
  trigger-id: string,
25
25
 
26
- // The account that the trigger is invoked for.
27
- account: account,
26
+ // The connection that the trigger is invoked for.
27
+ // Connection is required for all trigger operations.
28
+ connection: connection,
28
29
 
29
30
  // The store will contain the data that was stored in the trigger store the
30
31
  // last time the trigger was invoked.
31
32
  store: trigger-store,
33
+
34
+ // The input data for the trigger, serialized as a JSON object string.
35
+ // This contains the input data from the trigger configuration form.
36
+ serialized-input: string,
37
+ }
38
+
39
+ record action-context {
40
+ // Action ID is a unique identifier for the action that is requested to be
41
+ // invoked.
42
+ action-id: string,
43
+
44
+ // The connection that the action is invoked for.
45
+ // Connection is required for all action operations.
46
+ connection: connection,
47
+
48
+ // The input data for the action, serialized as a JSON object string.
49
+ // This contains the data passed from the previous step in the workflow.
50
+ serialized-input: string,
32
51
  }
33
52
 
34
53
  record trigger-response {
@@ -41,10 +60,17 @@ interface types {
41
60
  store: trigger-store,
42
61
  }
43
62
 
63
+ record action-response {
64
+ // The output data from the action, serialized as a JSON object string.
65
+ // This contains the data that will be passed to the next step in the workflow.
66
+ // The data must be a valid JSON object (not an array or primitive).
67
+ serialized-output: string
68
+ }
69
+
44
70
  record trigger-event {
45
71
  // The ID of the trigger event
46
72
  //
47
- // If the account used for the given instance of the trigger is the same,
73
+ // If the connection used for the given instance of the trigger is the same,
48
74
  // as seen before. Then the event will be ignored.
49
75
  //
50
76
  // A scheduler could therefore use an timestamp as the ID, to ensure that
@@ -81,7 +107,7 @@ interface types {
81
107
  /// Authentication failed. Typically due to an invalid or expired API key or token.
82
108
  unauthenticated,
83
109
 
84
- /// Authorization failed. The account is valid but does not have the necessary permissions.
110
+ /// Authorization failed. The connection is valid but does not have the necessary permissions.
85
111
  forbidden,
86
112
 
87
113
  /// The trigger is misconfigured. For example, a required setting is missing or invalid.
@@ -116,6 +142,18 @@ interface triggers {
116
142
 
117
143
  trigger-ids: func() -> result<list<string>, app-error>;
118
144
 
145
+ // Get the input schema for a specific trigger
146
+ // Returns a JSON Schema Draft 2020-12 schema as a string
147
+ // The schema may vary based on the connection in the context
148
+ // The trigger-id is extracted from the context
149
+ input-schema: func(context: trigger-context) -> result<string, app-error>;
150
+
151
+ // Get the output schema for a specific trigger
152
+ // Returns a JSON Schema Draft 2020-12 schema as a string
153
+ // The schema may vary based on the connection in the context
154
+ // The trigger-id is extracted from the context
155
+ output-schema: func(context: trigger-context) -> result<string, app-error>;
156
+
119
157
  // Fetch events
120
158
  //
121
159
  // There are some limitations to the function:
@@ -140,6 +178,47 @@ interface triggers {
140
178
  fetch-events: func(context: trigger-context) -> result<trigger-response, app-error>;
141
179
  }
142
180
 
181
+ interface actions {
182
+ use types.{action-context, action-response, app-error};
183
+
184
+ action-ids: func() -> result<list<string>, app-error>;
185
+
186
+ // Get the input schema for a specific action
187
+ // Returns a JSON Schema Draft 2020-12 schema as a string
188
+ // The schema may vary based on the connection in the context
189
+ // The action-id is extracted from the context
190
+ input-schema: func(context: action-context) -> result<string, app-error>;
191
+
192
+ // Get the output schema for a specific action
193
+ // Returns a JSON Schema Draft 2020-12 schema as a string
194
+ // The schema may vary based on the connection in the context
195
+ // The action-id is extracted from the context
196
+ output-schema: func(context: action-context) -> result<string, app-error>;
197
+
198
+ // Execute an action
199
+ //
200
+ // There are some limitations to the function:
201
+ // - It must return an `action-response` within 30 seconds
202
+ // - The serialized-output must be a valid JSON object serialized as a string
203
+ //
204
+ // Actions can perform various operations such as:
205
+ // - Making HTTP requests to external APIs
206
+ // - Processing and transforming data
207
+ // - Storing data for future use
208
+ // - Triggering other systems or workflows
209
+ //
210
+ // The action receives input data from the previous step and can return
211
+ // serialized output data to be passed to the next step in the workflow.
212
+ execute: func(context: action-context) -> result<action-response, app-error>;
213
+ }
214
+
215
+ interface environment {
216
+ // Get all environment variables
217
+ env-vars: func() -> list<tuple<string, string>>;
218
+ // Get a specific environment variable by name
219
+ env-var: func(name: string) -> option<string>;
220
+ }
221
+
143
222
  interface http {
144
223
  record response {
145
224
  status: u16,
@@ -192,5 +271,7 @@ interface http {
192
271
 
193
272
  world bridge {
194
273
  import http;
274
+ import environment;
195
275
  export triggers;
276
+ export actions;
196
277
  }
Binary file
Binary file
@@ -3,8 +3,16 @@
3
3
  require "timeout"
4
4
 
5
5
  module AppBridge
6
- # An app that can be used to fetch events.
6
+ # An app that can be used to fetch events and execute actions.
7
7
  class App
8
+ def initialize(component_path, environment_variables: {})
9
+ @component_path = component_path
10
+ @environment_variables = environment_variables
11
+ _rust_initialize(component_path, environment_variables)
12
+ rescue StandardError
13
+ raise InternalError, "Incompatible WASM file version"
14
+ end
15
+
8
16
  def fetch_events(context)
9
17
  response = request_events_with_timeout(context)
10
18
 
@@ -14,7 +22,15 @@ module AppBridge
14
22
  response
15
23
  end
16
24
 
17
- def polling_timeout
25
+ def execute_action(context)
26
+ response = request_action_with_timeout(context)
27
+
28
+ validate_action_response_size!(response.serialized_output)
29
+
30
+ response
31
+ end
32
+
33
+ def timeout_seconds
18
34
  30 # seconds
19
35
  end
20
36
 
@@ -32,8 +48,20 @@ module AppBridge
32
48
  raise StoreTooLargeError, "Store size exceeds 64 kB limit"
33
49
  end
34
50
 
51
+ def validate_action_response_size!(serialized_output)
52
+ return if serialized_output.size <= 64 * 1024
53
+
54
+ raise ActionResponseTooLargeError, "Action response size exceeds 64 kB limit"
55
+ end
56
+
57
+ def request_action_with_timeout(context)
58
+ Timeout.timeout(timeout_seconds, TimeoutError, "Action exceeded #{timeout_seconds} seconds") do
59
+ _rust_execute_action(context)
60
+ end
61
+ end
62
+
35
63
  def request_events_with_timeout(context)
36
- Timeout.timeout(polling_timeout, TimeoutError, "Polling exceeded #{polling_timeout} seconds") do
64
+ Timeout.timeout(timeout_seconds, TimeoutError, "Polling exceeded #{timeout_seconds} seconds") do
37
65
  _rust_fetch_events(context)
38
66
  end
39
67
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # When updating the version, please also update the version in the
4
+ # ext/app_bridge/Cargo.toml file to keep them in sync.
5
+
3
6
  module AppBridge
4
- VERSION = "2.0.1"
7
+ VERSION = "2.1.1"
5
8
  end
data/lib/app_bridge.rb CHANGED
@@ -3,17 +3,12 @@
3
3
  require_relative "app_bridge/version"
4
4
  require_relative "app_bridge/app"
5
5
 
6
- begin
7
- require "app_bridge/#{RUBY_VERSION.split(".").first(2).join(".")}/app_bridge"
8
- rescue LoadError
9
- require "app_bridge/app_bridge"
10
- end
11
-
12
6
  module AppBridge
13
7
  class Error < StandardError; end
14
8
  class TimeoutError < Error; end
15
9
  class TooManyEventsError < Error; end
16
10
  class StoreTooLargeError < Error; end
11
+ class ActionResponseTooLargeError < Error; end
17
12
 
18
13
  # Represents a trigger event that is recieved from the app.
19
14
  class TriggerEvent
@@ -23,3 +18,10 @@ module AppBridge
23
18
  end
24
19
  end
25
20
  end
21
+
22
+ # Load using the Ruby version as the directory name
23
+ begin
24
+ require "app_bridge/#{RUBY_VERSION.split(".").first(2).join(".")}/app_bridge"
25
+ rescue LoadError
26
+ require "app_bridge/app_bridge"
27
+ end
data/sig/app_bridge.rbs CHANGED
@@ -7,11 +7,15 @@ module AppBridge
7
7
 
8
8
  def triggers: () -> Array[String]
9
9
 
10
+ def actions: () -> Array[String]
11
+
10
12
  def fetch_events: (TriggerContext) -> TriggerResponse
13
+
14
+ def execute_action: (ActionContext) -> ActionResponse
11
15
  end
12
16
 
13
- class Account
14
- def self.new: (String, String, String) -> Account
17
+ class Connection
18
+ def self.new: (String, String, String) -> Connection
15
19
 
16
20
  def id: () -> String
17
21
 
@@ -39,12 +43,30 @@ module AppBridge
39
43
  end
40
44
 
41
45
  class TriggerContext
42
- def self.new: (String, Account, String) -> TriggerContext
46
+ def self.new: (String, Connection, String, String) -> TriggerContext
43
47
 
44
48
  def trigger_id: () -> String
45
49
 
46
- def account: () -> Account
50
+ def connection: () -> Connection
47
51
 
48
52
  def store: () -> String
53
+
54
+ def serialized_input: () -> String
55
+ end
56
+
57
+ class ActionContext
58
+ def self.new: (String, Connection, String) -> ActionContext
59
+
60
+ def action_id: () -> String
61
+
62
+ def connection: () -> Connection
63
+
64
+ def serialized_input: () -> String
65
+ end
66
+
67
+ class ActionResponse
68
+ def self.new: (String) -> ActionResponse
69
+
70
+ def serialized_output: () -> String
49
71
  end
50
72
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Rake task to run Rust tests
4
+ namespace :rust do
5
+ desc "Run Rust tests"
6
+ task :test do
7
+ puts "Running Rust tests..."
8
+ system("cargo test")
9
+ puts "Rust tests completed."
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Alexander Ross
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-14 00:00:00.000000000 Z
11
+ date: 2025-10-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The app_bridge gem is designed to enable seamless interaction with WebAssembly
14
14
  components that adhere to the WIT specification `standout:app`. It is developed
@@ -19,6 +19,7 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".editorconfig"
22
23
  - ".rspec"
23
24
  - ".rubocop.yml"
24
25
  - ".tool-versions"
@@ -33,6 +34,7 @@ files:
33
34
  - lib/app_bridge/version.rb
34
35
  - sig/app_bridge.rbs
35
36
  - tasks/fixtures.rake
37
+ - tasks/rust_test.rake
36
38
  homepage: https://github.com/standout/app_bridge
37
39
  licenses: []
38
40
  metadata: