app_bridge 0.8.4-x86_64-linux-musl → 2.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 +4 -4
- data/.tool-versions +1 -0
- data/ext/app_bridge/wit/world.wit +51 -12
- data/lib/app_bridge/3.2/app_bridge.so +0 -0
- data/lib/app_bridge/3.4/app_bridge.so +0 -0
- data/lib/app_bridge/app.rb +41 -0
- data/lib/app_bridge/version.rb +1 -1
- data/lib/app_bridge.rb +5 -0
- data/tasks/fixtures.rake +15 -8
- metadata +5 -4
- data/lib/app_bridge/3.1/app_bridge.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dfd7b1a3d7c0eeccfab8c0c66bd11bf2de807ddf24f2366cbc8ff28e5a34876
|
4
|
+
data.tar.gz: fd5d3f61590a6b15c841dc039ddad8f0d157e6b7f2e91d3015f1375981a073e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 596181651b83501fb0c2094f534bba2bbe7060c82c5af50db4545b984385ffbfaf2c41528a3458d544e1e81b1a0d7c178958327fc4703bd8f82fee24ec896607
|
7
|
+
data.tar.gz: 6ae909b246ab94b923d58ed94c6fd645be2298be60cdaed9c8a33674ca1f0302237412fba845da56106e2b24c17a3e2cd7def0bf728e2345db28e804e9b39049
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.4.2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
package standout:app@0.
|
1
|
+
package standout:app@2.0.0;
|
2
2
|
|
3
3
|
interface types {
|
4
4
|
// The trigger-store is a string that is used to store data between trigger
|
@@ -59,30 +59,69 @@ interface types {
|
|
59
59
|
// ensure that the event is only triggered once per order update.
|
60
60
|
id: string,
|
61
61
|
|
62
|
-
// The timestamp of the event.
|
63
|
-
// Must be a unix timestamp in milliseconds since epoch (UTC).
|
64
|
-
// In JavaScript `Date.now()` can be used to get the current timestamp in
|
65
|
-
// milliseconds.
|
66
|
-
timestamp: u64,
|
67
|
-
|
68
62
|
// Serialized data must be a JSON object serialized into a string
|
69
63
|
// Note that it is important that the root is a object, not an array,
|
70
64
|
// or another primitive type.
|
71
65
|
serialized-data: string,
|
72
66
|
}
|
67
|
+
|
68
|
+
/// A structured error that can be returned by for example a call to a trigger or action.
|
69
|
+
/// Contains a machine-readable code and a human-readable message.
|
70
|
+
record app-error {
|
71
|
+
/// The error code identifying the type of failure.
|
72
|
+
code: error-code,
|
73
|
+
|
74
|
+
/// A human-readable message describing the error in more detail.
|
75
|
+
message: string,
|
76
|
+
}
|
77
|
+
|
78
|
+
/// An enumeration of error codes that can be returned by a trigger implementation.
|
79
|
+
/// These codes help the platform and plugin developers distinguish between different types of failures.
|
80
|
+
variant error-code {
|
81
|
+
/// Authentication failed. Typically due to an invalid or expired API key or token.
|
82
|
+
unauthenticated,
|
83
|
+
|
84
|
+
/// Authorization failed. The account is valid but does not have the necessary permissions.
|
85
|
+
forbidden,
|
86
|
+
|
87
|
+
/// The trigger is misconfigured. For example, a required setting is missing or invalid.
|
88
|
+
misconfigured,
|
89
|
+
|
90
|
+
/// The target system does not support a required feature or endpoint.
|
91
|
+
unsupported,
|
92
|
+
|
93
|
+
/// The target system is rate-limiting requests. Try again later.
|
94
|
+
rate-limit,
|
95
|
+
|
96
|
+
/// The request timed out. The target system did not respond in time.
|
97
|
+
timeout,
|
98
|
+
|
99
|
+
/// The target system is currently unavailable or unreachable.
|
100
|
+
unavailable,
|
101
|
+
|
102
|
+
/// An unexpected internal error occurred in the plugin.
|
103
|
+
internal-error,
|
104
|
+
|
105
|
+
/// The response from the external system could not be parsed or was in an invalid format.
|
106
|
+
malformed-response,
|
107
|
+
|
108
|
+
/// A catch-all for all other types of errors. Should include a descriptive message.
|
109
|
+
other,
|
110
|
+
}
|
73
111
|
}
|
74
112
|
|
75
113
|
|
76
114
|
interface triggers {
|
77
|
-
use types.{trigger-context, trigger-event, trigger-response};
|
115
|
+
use types.{trigger-context, trigger-event, trigger-response, app-error};
|
78
116
|
|
79
|
-
|
117
|
+
trigger-ids: func() -> result<list<string>, app-error>;
|
80
118
|
|
81
119
|
// Fetch events
|
82
120
|
//
|
83
121
|
// There are some limitations to the function:
|
84
|
-
// - It must
|
85
|
-
// - It must return less than or equal to 100 events
|
122
|
+
// - It must a `trigger-response` within 30 seconds
|
123
|
+
// - It must return less than or equal to 100 `trigger-response.events`
|
124
|
+
// - It must not return more than 64 kB of data in the `trigger-response.store`
|
86
125
|
//
|
87
126
|
// If you need to fetch more events, you can return up to 100 events and then
|
88
127
|
// store the data needed for you to remember where you left off in the store.
|
@@ -98,7 +137,7 @@ interface triggers {
|
|
98
137
|
// the same events. That will ensure that the user that is building an
|
99
138
|
// integration with your trigger will not miss any events if your system is
|
100
139
|
// down for a short period of time.
|
101
|
-
fetch-events: func(context: trigger-context) -> trigger-response
|
140
|
+
fetch-events: func(context: trigger-context) -> result<trigger-response, app-error>;
|
102
141
|
}
|
103
142
|
|
104
143
|
interface http {
|
Binary file
|
Binary file
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "timeout"
|
4
|
+
|
5
|
+
module AppBridge
|
6
|
+
# An app that can be used to fetch events.
|
7
|
+
class App
|
8
|
+
def fetch_events(context)
|
9
|
+
response = request_events_with_timeout(context)
|
10
|
+
|
11
|
+
validate_number_of_events!(response.events)
|
12
|
+
validate_store_size!(response.store)
|
13
|
+
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def polling_timeout
|
18
|
+
30 # seconds
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def validate_number_of_events!(events)
|
24
|
+
return if events.size <= 100
|
25
|
+
|
26
|
+
raise TooManyEventsError, "Maximum 100 events allowed"
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_store_size!(store)
|
30
|
+
return if store.size <= 64 * 1024
|
31
|
+
|
32
|
+
raise StoreTooLargeError, "Store size exceeds 64 kB limit"
|
33
|
+
end
|
34
|
+
|
35
|
+
def request_events_with_timeout(context)
|
36
|
+
Timeout.timeout(polling_timeout, TimeoutError, "Polling exceeded #{polling_timeout} seconds") do
|
37
|
+
_rust_fetch_events(context)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/app_bridge/version.rb
CHANGED
data/lib/app_bridge.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "app_bridge/version"
|
4
|
+
require_relative "app_bridge/app"
|
5
|
+
|
4
6
|
begin
|
5
7
|
require "app_bridge/#{RUBY_VERSION.split(".").first(2).join(".")}/app_bridge"
|
6
8
|
rescue LoadError
|
@@ -9,6 +11,9 @@ end
|
|
9
11
|
|
10
12
|
module AppBridge
|
11
13
|
class Error < StandardError; end
|
14
|
+
class TimeoutError < Error; end
|
15
|
+
class TooManyEventsError < Error; end
|
16
|
+
class StoreTooLargeError < Error; end
|
12
17
|
|
13
18
|
# Represents a trigger event that is recieved from the app.
|
14
19
|
class TriggerEvent
|
data/tasks/fixtures.rake
CHANGED
@@ -2,36 +2,43 @@
|
|
2
2
|
|
3
3
|
require "English"
|
4
4
|
|
5
|
-
namespace :fixtures do
|
5
|
+
namespace :fixtures do # rubocop:disable Metrics/BlockLength
|
6
6
|
namespace :apps do
|
7
7
|
desc "Clean up build artifacts"
|
8
8
|
task :clean do
|
9
|
-
# In context of the path spec/fixtures/components/
|
9
|
+
# In context of the path spec/fixtures/components/rust_app.
|
10
10
|
# Execute cargo clean.
|
11
11
|
#
|
12
|
-
pwd = "spec/fixtures/components/
|
12
|
+
pwd = "spec/fixtures/components/rust_app"
|
13
13
|
pid = Process.spawn("cargo clean", chdir: pwd)
|
14
14
|
Process.wait(pid)
|
15
15
|
raise "Failed to clean build artifacts" unless $CHILD_STATUS.success?
|
16
16
|
|
17
17
|
# Remove the built wasm artifact.
|
18
|
-
pid = Process.spawn("rm
|
18
|
+
pid = Process.spawn("rm rust_app.wasm", chdir: "spec/fixtures/components")
|
19
19
|
Process.wait(pid)
|
20
20
|
end
|
21
21
|
|
22
22
|
desc "Compile the fixture apps"
|
23
|
-
task :
|
24
|
-
pwd = "spec/fixtures/components/
|
23
|
+
task :compile_rust do
|
24
|
+
pwd = "spec/fixtures/components/rust_app"
|
25
25
|
compile_pid = Process.spawn("cargo clean && cargo build --release --target wasm32-wasip2",
|
26
26
|
chdir: pwd)
|
27
27
|
Process.wait(compile_pid)
|
28
28
|
raise "Failed to build artifacts" unless $CHILD_STATUS.success?
|
29
29
|
|
30
|
-
move_pid = Process.spawn("mv #{pwd}/target/wasm32-wasip2/release/
|
30
|
+
move_pid = Process.spawn("mv #{pwd}/target/wasm32-wasip2/release/rust_app.wasm #{pwd}/../rust_app.wasm")
|
31
31
|
Process.wait(move_pid)
|
32
32
|
end
|
33
|
+
|
34
|
+
task :compile_js do
|
35
|
+
pwd = "spec/fixtures/components/js_app"
|
36
|
+
pid = Process.spawn("npm run build", chdir: pwd)
|
37
|
+
Process.wait(pid)
|
38
|
+
raise "Failed to build artifacts" unless $CHILD_STATUS.success?
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
36
43
|
desc "Build all fixtures"
|
37
|
-
task fixtures: %i[fixtures:apps:clean fixtures:apps:
|
44
|
+
task fixtures: %i[fixtures:apps:clean fixtures:apps:compile_rust fixtures:apps:compile_js]
|
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: 0.
|
4
|
+
version: 2.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-
|
11
|
+
date: 2025-04-14 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
|
@@ -21,14 +21,15 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- ".rspec"
|
23
23
|
- ".rubocop.yml"
|
24
|
+
- ".tool-versions"
|
24
25
|
- CHANGELOG.md
|
25
26
|
- README.md
|
26
27
|
- Rakefile
|
27
28
|
- ext/app_bridge/wit/world.wit
|
28
29
|
- lib/app_bridge.rb
|
29
|
-
- lib/app_bridge/3.1/app_bridge.so
|
30
30
|
- lib/app_bridge/3.2/app_bridge.so
|
31
31
|
- lib/app_bridge/3.4/app_bridge.so
|
32
|
+
- lib/app_bridge/app.rb
|
32
33
|
- lib/app_bridge/version.rb
|
33
34
|
- sig/app_bridge.rbs
|
34
35
|
- tasks/fixtures.rake
|
@@ -49,7 +50,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
50
|
requirements:
|
50
51
|
- - ">="
|
51
52
|
- !ruby/object:Gem::Version
|
52
|
-
version: '3.
|
53
|
+
version: '3.2'
|
53
54
|
- - "<"
|
54
55
|
- !ruby/object:Gem::Version
|
55
56
|
version: 3.5.dev
|
Binary file
|