triangulum 0.30.2-aarch64-linux-gnu → 0.31.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 +4 -4
- data/lib/triangulum/executor.rb +49 -0
- data/lib/triangulum/flow_schema_extraction.rb +71 -0
- data/lib/triangulum/js/flow-schema-extraction.js +356686 -0
- data/lib/triangulum/js/single-validation.js +3880 -3807
- data/lib/triangulum/validation.rb +2 -41
- data/lib/triangulum/version.rb +1 -1
- data/lib/triangulum.rb +2 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f6ae428decfce1bbbd90d6421c3cb5c56dc933a7246e9a9272d865711582fe1
|
|
4
|
+
data.tar.gz: 48a073c2426dbc4eb0a60e8858960adec9828d629ba1c27044b68cc3a67480e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd82b41148b1aa5c7b89807f559e89aeed8c9f8934c5d1888e24479a2d798d8aca15112b6019ab4f0f2d1473ea8a836c787e710bf507361c57738282179b2e7e
|
|
7
|
+
data.tar.gz: 7a833f105973e0e8053526eab97566be55981f564f1dcf1a07b0a0f0aba6b1bb416e918310948699371229a5d45773eb7c84627fe29f6d95531a40a6d43f2656
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Triangulum
|
|
4
|
+
# == Triangulum::Executor
|
|
5
|
+
# This module provides the execute methods for triangulum
|
|
6
|
+
module Executor
|
|
7
|
+
class TriangulumFailed < Triangulum::Error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class BunNotFound < Triangulum::Error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
BUN_EXE = Dir.glob(File.expand_path('../../exe/*/bun', __dir__)).find do |path|
|
|
14
|
+
platform = Gem::Platform.new(File.basename(File.dirname(path)))
|
|
15
|
+
Gem::Platform.match_gem?(platform, Gem::Platform.local.to_s)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
IS_RUBY_PLATFORM_GEM = Dir.glob(File.expand_path('../../exe/*/bun', __dir__)).empty?
|
|
19
|
+
|
|
20
|
+
def run_ts_triangulum(entrypoint, input)
|
|
21
|
+
stdout_s, stderr_s, status = Open3.capture3(
|
|
22
|
+
bun, 'run', entrypoint,
|
|
23
|
+
stdin_data: input
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
unless status.success?
|
|
27
|
+
status_info = if status.signaled?
|
|
28
|
+
"SIGNAL: #{status.termsig}"
|
|
29
|
+
else
|
|
30
|
+
"STATUS: #{status.exitstatus}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
raise TriangulumFailed, "#{status_info}\n\nOUT:\n#{stdout_s}\n\nERR:\n#{stderr_s}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
stdout_s
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def bun
|
|
40
|
+
if IS_RUBY_PLATFORM_GEM
|
|
41
|
+
'bun'
|
|
42
|
+
else
|
|
43
|
+
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?
|
|
44
|
+
|
|
45
|
+
BUN_EXE
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Triangulum
|
|
4
|
+
# == Triangulum::FlowSchemaExtraction
|
|
5
|
+
# This class implements the extraction of flow schemas using the typescript package
|
|
6
|
+
class FlowSchemaExtraction
|
|
7
|
+
include Executor
|
|
8
|
+
|
|
9
|
+
Result = Struct.new(:flow, :subflow_parameters, keyword_init: true)
|
|
10
|
+
SchematizedObject = Struct.new(:id, :input_schema, :output_schema, keyword_init: true)
|
|
11
|
+
|
|
12
|
+
ENTRYPOINT = File.expand_path('js/flow-schema-extraction.js', __dir__)
|
|
13
|
+
|
|
14
|
+
attr_reader :flow, :function_definitions, :data_types
|
|
15
|
+
|
|
16
|
+
def initialize(flow, runtime_function_definitions, data_types)
|
|
17
|
+
@flow = flow
|
|
18
|
+
@function_definitions = runtime_function_definitions
|
|
19
|
+
@data_types = data_types
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def extract
|
|
23
|
+
input = serialize_input
|
|
24
|
+
|
|
25
|
+
output = run_ts_triangulum(ENTRYPOINT, input)
|
|
26
|
+
|
|
27
|
+
parse_output(output)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def serialize_input
|
|
33
|
+
input = []
|
|
34
|
+
|
|
35
|
+
input << Base64.strict_encode64(flow.to_proto)
|
|
36
|
+
input << ''
|
|
37
|
+
|
|
38
|
+
function_definitions.each do |rfd|
|
|
39
|
+
input << Base64.strict_encode64(rfd.to_proto)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
input << ''
|
|
43
|
+
|
|
44
|
+
data_types.each do |dt|
|
|
45
|
+
input << Base64.strict_encode64(dt.to_proto)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
input << ''
|
|
49
|
+
|
|
50
|
+
input.join("\n")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def parse_output(output)
|
|
54
|
+
json = JSON.parse(output, symbolize_names: true)
|
|
55
|
+
|
|
56
|
+
Result.new(
|
|
57
|
+
flow: SchematizedObject.new(
|
|
58
|
+
input_schema: json[:flow][:inputSchema],
|
|
59
|
+
output_schema: json[:flow][:outputSchema]
|
|
60
|
+
),
|
|
61
|
+
subflow_parameters: json[:subflowParameters].map do |param|
|
|
62
|
+
SchematizedObject.new(
|
|
63
|
+
id: param[:id],
|
|
64
|
+
input_schema: param[:inputSchema],
|
|
65
|
+
output_schema: param[:outputSchema]
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|