app_bridge 0.6.0-arm64-darwin

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fbac4e3f1110df2e77bd8ee08bd108691a7c820381f6720e84e9d76a84177dd9
4
+ data.tar.gz: 77d9173a687a3de9aa4fb47425af3ccba303933dfbf5d2a8507ef5c137f49d11
5
+ SHA512:
6
+ metadata.gz: b234de1a378380594688bf04432981243ce8cac48d7c662b47be94bda1a6830c952db19ffb7cafba86cae09bff3f5477315e6d280b4b980fb66390453ac2f154
7
+ data.tar.gz: e3710be91f912392f2e962a49a8dfe6d4fbce8182795e9a03655c0724a4be0d53c3b99ca70be8a1d3e0e9289cf00d30bf40f68acdf3afa6a940bd76bec74d873
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+ NewCops: enable
4
+
5
+ Style/StringLiterals:
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ EnforcedStyle: double_quotes
10
+
11
+
12
+ Metrics/BlockLength:
13
+ Exclude:
14
+ - 'spec/**/*_spec.rb'
15
+ - '*.gemspec'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-01-27
4
+
5
+ - Initial release
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Standout App Bridge
2
+
3
+ `app_bridge` is a Ruby gem designed to facilitate communication with WebAssembly components that implement the WIT specification `standout:app`. This gem is developed for use in Standout's products.
4
+
5
+ ## Installation
6
+
7
+ Add the following line to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'app_bridge', github: 'standout/app_bridge'
11
+ ```
12
+
13
+ Then, install the gem by running:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ To use this gem, you need a WebAssembly component that adheres to the specification defined in `ext/app_bridge/wit/world.wit`.
22
+
23
+ You can check out the example components in `spec/fixtures/components` to see how such a component should be structured.
24
+
25
+ Once you have a WebAssembly component, you can use the gem as follows:
26
+
27
+ ```ruby
28
+ require 'app_bridge'
29
+
30
+ app = AppBridge::App.new('path/to/your/component.wasm')
31
+ app.triggers # => ['trigger1', 'trigger2']
32
+ ```
33
+
34
+ More documentation and features will be added as the gem evolves.
35
+
36
+ ## Development
37
+
38
+ To contribute or modify this gem, ensure you have the following dependencies installed:
39
+
40
+ - **Ruby 3.3.0** (or later)
41
+ - **Rust 1.84.0** (or later)
42
+
43
+ ### Setting Up the Development Environment
44
+
45
+ Run the following command to setup and install additional dependencies:
46
+
47
+ ```bash
48
+ bin/setup
49
+ ```
50
+
51
+ Then, to compile example applications, run tests, and perform syntax checks, execute:
52
+
53
+ ```bash
54
+ rake
55
+ ```
56
+
57
+ ### Useful Commands
58
+
59
+ - **Interactive Console:** Run `bin/console` to interactively test the code.
60
+ - **Full Test Suite & Linting:** Run `rake` to compile, execute tests, and perform syntax checks.
61
+ - **Run Tests Only:** Execute `rake spec` to run only the test suite.
62
+ - **Linting:** Run `rake rubocop` to check code style and formatting.
63
+ - **Compile Example Applications:** Use `rake fixtures` to build the example apps.
64
+
65
+ To install this gem locally for testing purposes, run:
66
+
67
+ ```bash
68
+ bundle exec rake install
69
+ ```
70
+
71
+ ## Release & Distribution
72
+
73
+ This gem is **not** published to RubyGems. It is intended for internal use within Standout's products only.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ require "rb_sys/extensiontask"
13
+
14
+ task build: :compile
15
+
16
+ GEMSPEC = Gem::Specification.load("app_bridge.gemspec")
17
+
18
+ RbSys::ExtensionTask.new("app_bridge", GEMSPEC) do |ext|
19
+ ext.lib_dir = "lib/app_bridge"
20
+ end
21
+
22
+ # Load all project specific rake tasks
23
+ Dir.glob(File.expand_path("tasks/**/*.rake", __dir__)).each { |file| load file }
24
+
25
+ task default: %i[fixtures compile spec rubocop]
@@ -0,0 +1,157 @@
1
+ package standout:app@0.3.0;
2
+
3
+ interface types {
4
+ // The trigger-store is a string that is used to store data between trigger
5
+ // invocations. It is unique per trigger instance and is persisted between
6
+ // invocations.
7
+ //
8
+ // You can store any string here. We suggest that you use a serialized
9
+ // JSON object or similar since that will give you some flexibility if you
10
+ // need to add more data to the store.
11
+ type trigger-store = string;
12
+
13
+ record account {
14
+ id: string,
15
+ name: string,
16
+ // The account data is a JSON object serialized into a string. The JSON root
17
+ // will always be an object.
18
+ serialized-data: string,
19
+ }
20
+
21
+ record trigger-context {
22
+ // Trigger ID is a unique identifier for the trigger that is requested to be
23
+ // invoked.
24
+ trigger-id: string,
25
+
26
+ // The account that the trigger is invoked for.
27
+ account: account,
28
+
29
+ // The store will contain the data that was stored in the trigger store the
30
+ // last time the trigger was invoked.
31
+ store: trigger-store,
32
+ }
33
+
34
+ record trigger-response {
35
+ // The trigger events, each event will be used to spawn a new workflow
36
+ // execution in Standouts integration plattform.
37
+ events: list<trigger-event>,
38
+
39
+ // The updated store will be stored and used the next time the trigger is
40
+ // invoked.
41
+ store: trigger-store,
42
+ }
43
+
44
+ record trigger-event {
45
+ // The ID of the trigger event
46
+ //
47
+ // If the account used for the given instance of the trigger is the same,
48
+ // as seen before. Then the event will be ignored.
49
+ //
50
+ // A scheduler could therefore use an timestamp as the ID, to ensure that
51
+ // the event is only triggered once per given time.
52
+ //
53
+ // A trigger that acts on created orders in a e-commerce system could use
54
+ // the order ID as the ID, to ensure that the event is only triggered once
55
+ // per order.
56
+ //
57
+ // A trigger that acts on updated orders in a e-commerce system could use
58
+ // the order ID in combination with an updated at timestamp as the ID, to
59
+ // ensure that the event is only triggered once per order update.
60
+ id: string,
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
+ // Serialized data must be a JSON object serialized into a string
69
+ // Note that it is important that the root is a object, not an array,
70
+ // or another primitive type.
71
+ serialized-data: string,
72
+ }
73
+ }
74
+
75
+
76
+ interface triggers {
77
+ use types.{trigger-context, trigger-event, trigger-response};
78
+
79
+ get-triggers: func() -> list<string>;
80
+
81
+ // Fetch events
82
+ //
83
+ // There are some limitations to the function:
84
+ // - It must return within 30 seconds
85
+ // - It must return less than or equal to 100 events
86
+ //
87
+ // If you need to fetch more events, you can return up to 100 events and then
88
+ // store the data needed for you to remember where you left off in the store.
89
+ // The next time the trigger is invoked, you can use the store to continue
90
+ // where you left off.
91
+ //
92
+ // If you do not pass the limitations the return value will be ignored. We
93
+ // will not handle any events and we persist the store that was returned in
94
+ // the response.
95
+ //
96
+ // That also means that you should implement your fetch event function in a
97
+ // way that it can be called multiple times using the same context and return
98
+ // the same events. That will ensure that the user that is building an
99
+ // integration with your trigger will not miss any events if your system is
100
+ // down for a short period of time.
101
+ fetch-events: func(context: trigger-context) -> trigger-response;
102
+ }
103
+
104
+ interface http {
105
+ record response {
106
+ status: u16,
107
+ headers: headers,
108
+ body: string,
109
+ }
110
+
111
+ record request {
112
+ method: method,
113
+ url: string,
114
+ headers: headers,
115
+ body: string,
116
+ }
117
+
118
+ variant request-error {
119
+ other(string)
120
+ }
121
+
122
+ type headers = list<tuple<string, string>>;
123
+
124
+ resource request-builder {
125
+ constructor();
126
+
127
+ method: func(method: method) -> request-builder;
128
+ url: func(url: string) -> request-builder;
129
+
130
+ // Add a header to the request
131
+ header: func(key: string, value: string) -> request-builder;
132
+ headers: func(headers: list<tuple<string, string>>) -> request-builder;
133
+
134
+ // Add a body to the request
135
+ body: func(body: string) -> request-builder;
136
+
137
+ object: func() -> request;
138
+
139
+ // Send the request
140
+ send: func() -> result<response, request-error>;
141
+ }
142
+
143
+ variant method {
144
+ get,
145
+ post,
146
+ put,
147
+ delete,
148
+ patch,
149
+ options,
150
+ head,
151
+ }
152
+ }
153
+
154
+ world bridge {
155
+ import http;
156
+ export triggers;
157
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppBridge
4
+ VERSION = "0.6.0"
5
+ end
data/lib/app_bridge.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "app_bridge/version"
4
+ require_relative "app_bridge/app_bridge"
5
+
6
+ module AppBridge
7
+ class Error < StandardError; end
8
+
9
+ # Represents a trigger event that is recieved from the app.
10
+ class TriggerEvent
11
+ def inspect
12
+ "#<AppBridge::TriggerEvent(id: #{id.inspect}, timestamp: #{timestamp.inspect}, " \
13
+ "serialized_data: #{serialized_data.inspect})>"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module AppBridge
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+
5
+ class App
6
+ def initialize: (String) -> void
7
+
8
+ def triggers : () -> Array[String]
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "English"
4
+
5
+ namespace :fixtures do
6
+ namespace :apps do
7
+ desc "Clean up build artifacts"
8
+ task :clean do
9
+ # In context of the path spec/fixtures/components/example.
10
+ # Execute cargo clean.
11
+ #
12
+ pwd = "spec/fixtures/components/example"
13
+ pid = Process.spawn("cargo clean", chdir: pwd)
14
+ Process.wait(pid)
15
+ raise "Failed to clean build artifacts" unless $CHILD_STATUS.success?
16
+
17
+ # Remove the built wasm artifact.
18
+ pid = Process.spawn("rm example.wasm", chdir: "spec/fixtures/components")
19
+ Process.wait(pid)
20
+ end
21
+
22
+ desc "Compile the fixture apps"
23
+ task :compile do
24
+ pwd = "spec/fixtures/components/example"
25
+ compile_pid = Process.spawn("cargo clean && cargo build --release --target wasm32-wasip2",
26
+ chdir: pwd)
27
+ Process.wait(compile_pid)
28
+ raise "Failed to build artifacts" unless $CHILD_STATUS.success?
29
+
30
+ move_pid = Process.spawn("mv #{pwd}/target/wasm32-wasip2/release/example.wasm #{pwd}/../example.wasm")
31
+ Process.wait(move_pid)
32
+ end
33
+ end
34
+ end
35
+
36
+ desc "Build all fixtures"
37
+ task fixtures: %i[fixtures:apps:clean fixtures:apps:compile]
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: app_bridge
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: arm64-darwin
6
+ authors:
7
+ - Alexander Ross
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-02-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The app_bridge gem is designed to enable seamless interaction with WebAssembly
14
+ components that adhere to the WIT specification `standout:app`. It is developed
15
+ for use in Standout's products.
16
+ email:
17
+ - ross@standout.se
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - CHANGELOG.md
25
+ - README.md
26
+ - Rakefile
27
+ - ext/app_bridge/wit/world.wit
28
+ - lib/app_bridge.rb
29
+ - lib/app_bridge/3.1/app_bridge.bundle
30
+ - lib/app_bridge/3.2/app_bridge.bundle
31
+ - lib/app_bridge/3.4/app_bridge.bundle
32
+ - lib/app_bridge/version.rb
33
+ - sig/app_bridge.rbs
34
+ - tasks/fixtures.rake
35
+ homepage: https://github.com/standout/app_bridge
36
+ licenses: []
37
+ metadata:
38
+ allowed_push_host: https://rubygems.org
39
+ homepage_uri: https://github.com/standout/app_bridge
40
+ source_code_uri: https://github.com/standout/app_bridge
41
+ changelog_uri: https://github.com/standout/app_bridge/blob/main/CHANGELOG.md
42
+ rubygems_mfa_required: 'true'
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '3.1'
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.5.dev
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 3.3.11
60
+ requirements: []
61
+ rubygems_version: 3.5.23
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Communication layer for Standout integration apps
65
+ test_files: []