triangulum 0.4.0-aarch64-linux-gnu
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 +7 -0
- data/README.md +77 -0
- data/exe/aarch64-linux-gnu/bun +0 -0
- data/lib/triangulum/validation.rb +92 -0
- data/lib/triangulum/version.rb +5 -0
- data/lib/triangulum.rb +12 -0
- metadata +207 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 274bd950241a93f37d010fc0ba39bcc1100d6623ea2f23b5b5d18560f215e955
|
|
4
|
+
data.tar.gz: cec89ed67cde9aa97bae552055405c2a352c21be922baf523276c4f2d40d5ed7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9c93fd252a5088514998e758b33abe0f2f607519097c670d70233732ecc6a112b6d675c2d3b30fcc87e40de0094adeb096ecfc1fa71ea52cc6d77ce26b203b9f
|
|
7
|
+
data.tar.gz: a473ca1463a0e766679228b0511d715e7c7582677513a58455088509659376d35eeaccce7f7ba42f002182a5af04a7f19727c101c592a06817648bb767cf15f8
|
data/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Triangulum Ruby Gem
|
|
2
|
+
|
|
3
|
+
Ruby bindings for the [Triangulum](https://github.com/code0-tech/triangulum) validation layer. This gem wraps the TypeScript library and a bundled [Bun](https://bun.sh) runtime to validate flows using the TypeScript compiler.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'triangulum'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Platform-specific gems are published for:
|
|
14
|
+
|
|
15
|
+
- `arm64-darwin` (macOS Apple Silicon)
|
|
16
|
+
- `x86_64-darwin` (macOS Intel)
|
|
17
|
+
- `x86_64-linux-gnu` (Linux x64)
|
|
18
|
+
- `x86_64-linux-musl` (Linux x64 musl)
|
|
19
|
+
- `aarch64-linux-gnu` (Linux ARM64)
|
|
20
|
+
- `aarch64-linux-musl` (Linux ARM64 musl)
|
|
21
|
+
|
|
22
|
+
If Bundler doesn't automatically select the correct platform gem, add your platform:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bundle lock --add-platform x86_64-linux-gnu
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
result = Triangulum::Validation.new(flow, runtime_function_definitions, data_types).validate
|
|
32
|
+
|
|
33
|
+
result.valid? # => true / false
|
|
34
|
+
result.return_type # => "void"
|
|
35
|
+
result.diagnostics # => [Triangulum::Validation::Diagnostic, ...]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The arguments are [Tucana](https://github.com/code0-tech/tucana) protobuf objects:
|
|
39
|
+
|
|
40
|
+
- `flow` — `Tucana::Shared::ValidationFlow`
|
|
41
|
+
- `runtime_function_definitions` — `Array<Tucana::Shared::RuntimeFunctionDefinition>`
|
|
42
|
+
- `data_types` — `Array<Tucana::Shared::DefinitionDataType>`
|
|
43
|
+
|
|
44
|
+
### Diagnostics
|
|
45
|
+
|
|
46
|
+
Each diagnostic contains:
|
|
47
|
+
|
|
48
|
+
| Field | Description |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `message` | Human-readable error description |
|
|
51
|
+
| `code` | TypeScript diagnostic code |
|
|
52
|
+
| `severity` | `"error"` or `"warning"` |
|
|
53
|
+
| `node_id` | ID of the node that caused the error |
|
|
54
|
+
| `parameter_index` | Index of the parameter that caused the error |
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
Prerequisites: [Bun](https://bun.sh) installed locally for building the entrypoint.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cd gem
|
|
62
|
+
bundle install
|
|
63
|
+
bundle exec rake prepare_build # downloads bun binaries + builds JS entrypoint
|
|
64
|
+
bundle exec rake # run tests and rubocop
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Building platform gems
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
bundle exec rake package
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This will download bun binaries (with SHA256 checksum verification) for all supported platforms and build a `.gem` file for each.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
See [LICENSE](../LICENSE).
|
|
Binary file
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Triangulum
|
|
4
|
+
# == Triangulum::Validation
|
|
5
|
+
# This class implements the validation using the typescript package
|
|
6
|
+
class Validation
|
|
7
|
+
class TriangulumFailed < Triangulum::Error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class BunNotFound < Triangulum::Error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Result = Struct.new(:valid?, :return_type, :diagnostics, keyword_init: true)
|
|
14
|
+
Diagnostic = Struct.new(:message, :code, :severity, :node_id, :parameter_index, keyword_init: true)
|
|
15
|
+
|
|
16
|
+
ENTRYPOINT = File.expand_path('js/single-validation.js', __dir__)
|
|
17
|
+
BUN_EXE = Dir.glob(File.expand_path('../../exe/*/bun', __dir__)).find do |path|
|
|
18
|
+
platform = Gem::Platform.new(File.basename(File.dirname(path)))
|
|
19
|
+
Gem::Platform.match_gem?(platform, Gem::Platform.local.to_s)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
attr_reader :flow, :runtime_function_definitions, :data_types
|
|
23
|
+
|
|
24
|
+
def initialize(flow, runtime_function_definitions, data_types)
|
|
25
|
+
@flow = flow
|
|
26
|
+
@runtime_function_definitions = runtime_function_definitions
|
|
27
|
+
@data_types = data_types
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def validate
|
|
31
|
+
input = serialize_input
|
|
32
|
+
|
|
33
|
+
output = run_ts_triangulum(input)
|
|
34
|
+
|
|
35
|
+
parse_output(output)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def run_ts_triangulum(input)
|
|
41
|
+
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?
|
|
42
|
+
|
|
43
|
+
stdout_s, stderr_s, status = Open3.capture3(
|
|
44
|
+
BUN_EXE, 'run', ENTRYPOINT,
|
|
45
|
+
stdin_data: input
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
raise TriangulumFailed, "OUT:\n#{stdout_s}\n\nERR:\n#{stderr_s}" unless status.success?
|
|
49
|
+
|
|
50
|
+
stdout_s
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def serialize_input
|
|
54
|
+
input = []
|
|
55
|
+
|
|
56
|
+
input << Base64.strict_encode64(flow.to_proto)
|
|
57
|
+
input << ''
|
|
58
|
+
|
|
59
|
+
runtime_function_definitions.each do |rfd|
|
|
60
|
+
input << Base64.strict_encode64(rfd.to_proto)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
input << ''
|
|
64
|
+
|
|
65
|
+
data_types.each do |dt|
|
|
66
|
+
input << Base64.strict_encode64(dt.to_proto)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
input << ''
|
|
70
|
+
|
|
71
|
+
input.join("\n")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def parse_output(output)
|
|
75
|
+
json = JSON.parse(output, symbolize_names: true)
|
|
76
|
+
|
|
77
|
+
Result.new(
|
|
78
|
+
valid?: json[:isValid],
|
|
79
|
+
return_type: json[:returnType],
|
|
80
|
+
diagnostics: json[:diagnostics].map do |diagnostic|
|
|
81
|
+
Diagnostic.new(
|
|
82
|
+
message: diagnostic[:message],
|
|
83
|
+
code: diagnostic[:code],
|
|
84
|
+
severity: diagnostic[:severity],
|
|
85
|
+
node_id: diagnostic[:nodeId],
|
|
86
|
+
parameter_index: diagnostic[:parameterIndex]
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/triangulum.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: triangulum
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.0
|
|
5
|
+
platform: aarch64-linux-gnu
|
|
6
|
+
authors:
|
|
7
|
+
- Niklas van Schrick
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: base64
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.3'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.3'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: json
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.19'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.19'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: open3
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.2'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0.2'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: tucana
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0.0'
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 0.0.62
|
|
64
|
+
type: :runtime
|
|
65
|
+
prerelease: false
|
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - "~>"
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0.0'
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: 0.0.62
|
|
74
|
+
- !ruby/object:Gem::Dependency
|
|
75
|
+
name: irb
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '1.17'
|
|
81
|
+
type: :development
|
|
82
|
+
prerelease: false
|
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '1.17'
|
|
88
|
+
- !ruby/object:Gem::Dependency
|
|
89
|
+
name: rake
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '13.0'
|
|
95
|
+
type: :development
|
|
96
|
+
prerelease: false
|
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - "~>"
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '13.0'
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: rubyzip
|
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - "~>"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '2.3'
|
|
109
|
+
type: :development
|
|
110
|
+
prerelease: false
|
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - "~>"
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '2.3'
|
|
116
|
+
- !ruby/object:Gem::Dependency
|
|
117
|
+
name: rspec
|
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - "~>"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '3.0'
|
|
123
|
+
type: :development
|
|
124
|
+
prerelease: false
|
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - "~>"
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '3.0'
|
|
130
|
+
- !ruby/object:Gem::Dependency
|
|
131
|
+
name: rubocop
|
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - "~>"
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '1.21'
|
|
137
|
+
type: :development
|
|
138
|
+
prerelease: false
|
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - "~>"
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '1.21'
|
|
144
|
+
- !ruby/object:Gem::Dependency
|
|
145
|
+
name: rubocop-rake
|
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
|
147
|
+
requirements:
|
|
148
|
+
- - "~>"
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: 0.7.0
|
|
151
|
+
type: :development
|
|
152
|
+
prerelease: false
|
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
154
|
+
requirements:
|
|
155
|
+
- - "~>"
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: 0.7.0
|
|
158
|
+
- !ruby/object:Gem::Dependency
|
|
159
|
+
name: rubocop-rspec
|
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
|
161
|
+
requirements:
|
|
162
|
+
- - "~>"
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: '3.0'
|
|
165
|
+
type: :development
|
|
166
|
+
prerelease: false
|
|
167
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - "~>"
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: '3.0'
|
|
172
|
+
email:
|
|
173
|
+
- mc.taucher2003@gmail.com
|
|
174
|
+
executables: []
|
|
175
|
+
extensions: []
|
|
176
|
+
extra_rdoc_files: []
|
|
177
|
+
files:
|
|
178
|
+
- README.md
|
|
179
|
+
- exe/aarch64-linux-gnu/bun
|
|
180
|
+
- lib/triangulum.rb
|
|
181
|
+
- lib/triangulum/validation.rb
|
|
182
|
+
- lib/triangulum/version.rb
|
|
183
|
+
homepage: https://github.com/code0-tech/triangulum
|
|
184
|
+
licenses:
|
|
185
|
+
- MIT
|
|
186
|
+
metadata:
|
|
187
|
+
homepage_uri: https://github.com/code0-tech/triangulum
|
|
188
|
+
changelog_uri: https://github.com/code0-tech/triangulum/releases
|
|
189
|
+
rubygems_mfa_required: 'true'
|
|
190
|
+
rdoc_options: []
|
|
191
|
+
require_paths:
|
|
192
|
+
- lib
|
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
|
+
requirements:
|
|
195
|
+
- - ">="
|
|
196
|
+
- !ruby/object:Gem::Version
|
|
197
|
+
version: 3.1.0
|
|
198
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
|
+
requirements:
|
|
200
|
+
- - ">="
|
|
201
|
+
- !ruby/object:Gem::Version
|
|
202
|
+
version: '0'
|
|
203
|
+
requirements: []
|
|
204
|
+
rubygems_version: 3.6.9
|
|
205
|
+
specification_version: 4
|
|
206
|
+
summary: Triangulum is the CodeZero validation layer
|
|
207
|
+
test_files: []
|