app_bridge 2.0.1-x86_64-linux-musl → 3.0.0-x86_64-linux-musl

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: 5a361775c8d0d2e50639cec2345c31c975a42cabf457846d93ecde4e07283e12
4
- data.tar.gz: a4f314737b37487c79c237a016ec7961ca792931ebfb65593214360f09ace30b
3
+ metadata.gz: df8a941497724fcf8f2ef45927bb3a30988bd463c9bec5995775046303eef543
4
+ data.tar.gz: 1ce8dddca0bbf398d5bc5539f92b6edca9f21f9574b24e2f3e1f47ff8eba6f07
5
5
  SHA512:
6
- metadata.gz: 0cacb64beb43d9a059447cdc2b652dfbb82260c0a609112d782c5e000b9c6c5ca191ff265ee8710aafcc434a75b79f2210a444c980a13545e3fbdc4f89b48459
7
- data.tar.gz: 57dafe0731bfcb61a1ee2548cf4223aa5745c8038c7ce9ae3dbbac9d61d383cb68543db0ed8a397222dc47eb6f63b1dbf67f5ec102e1bec304fb168dad007de0
6
+ metadata.gz: 243a0137a17a4152a514665344f3132a7e3141647bbfd8ac2f57319349bb66aa44b98377547b102ef93d0534b9b5ef1ca58f21f7b53a2269d3d066494fff8a1a
7
+ data.tar.gz: 0bac68f0c31440845b6f080a4b205baa30774225acdbb07c28904580f1fd1b84142e882a72228f0461028697cf3341cbf80ae769ceb0ae1da18da06868338aff
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@3.0.0;
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.
@@ -107,6 +133,12 @@ interface types {
107
133
 
108
134
  /// A catch-all for all other types of errors. Should include a descriptive message.
109
135
  other,
136
+
137
+ /// Complete the current workflow execution.
138
+ complete-workflow,
139
+
140
+ /// Complete the parent step execution.
141
+ complete-parent,
110
142
  }
111
143
  }
112
144
 
@@ -116,6 +148,18 @@ interface triggers {
116
148
 
117
149
  trigger-ids: func() -> result<list<string>, app-error>;
118
150
 
151
+ // Get the input 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
+ input-schema: func(context: trigger-context) -> result<string, app-error>;
156
+
157
+ // Get the output schema for a specific trigger
158
+ // Returns a JSON Schema Draft 2020-12 schema as a string
159
+ // The schema may vary based on the connection in the context
160
+ // The trigger-id is extracted from the context
161
+ output-schema: func(context: trigger-context) -> result<string, app-error>;
162
+
119
163
  // Fetch events
120
164
  //
121
165
  // There are some limitations to the function:
@@ -140,6 +184,47 @@ interface triggers {
140
184
  fetch-events: func(context: trigger-context) -> result<trigger-response, app-error>;
141
185
  }
142
186
 
187
+ interface actions {
188
+ use types.{action-context, action-response, app-error};
189
+
190
+ action-ids: func() -> result<list<string>, app-error>;
191
+
192
+ // Get the input 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
+ input-schema: func(context: action-context) -> result<string, app-error>;
197
+
198
+ // Get the output schema for a specific action
199
+ // Returns a JSON Schema Draft 2020-12 schema as a string
200
+ // The schema may vary based on the connection in the context
201
+ // The action-id is extracted from the context
202
+ output-schema: func(context: action-context) -> result<string, app-error>;
203
+
204
+ // Execute an action
205
+ //
206
+ // There are some limitations to the function:
207
+ // - It must return an `action-response` within 30 seconds
208
+ // - The serialized-output must be a valid JSON object serialized as a string
209
+ //
210
+ // Actions can perform various operations such as:
211
+ // - Making HTTP requests to external APIs
212
+ // - Processing and transforming data
213
+ // - Storing data for future use
214
+ // - Triggering other systems or workflows
215
+ //
216
+ // The action receives input data from the previous step and can return
217
+ // serialized output data to be passed to the next step in the workflow.
218
+ execute: func(context: action-context) -> result<action-response, app-error>;
219
+ }
220
+
221
+ interface environment {
222
+ // Get all environment variables
223
+ env-vars: func() -> list<tuple<string, string>>;
224
+ // Get a specific environment variable by name
225
+ env-var: func(name: string) -> option<string>;
226
+ }
227
+
143
228
  interface http {
144
229
  record response {
145
230
  status: u16,
@@ -192,5 +277,7 @@ interface http {
192
277
 
193
278
  world bridge {
194
279
  import http;
280
+ import environment;
195
281
  export triggers;
282
+ export actions;
196
283
  }
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 = "3.0.0"
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: 3.0.0
5
5
  platform: x86_64-linux-musl
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-29 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: