trailblazer-developer 0.0.22 → 0.0.23
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/CHANGES.md +5 -0
- data/Gemfile +0 -3
- data/lib/trailblazer/developer/trace/focusable.rb +0 -2
- data/lib/trailblazer/developer/version.rb +1 -1
- data/lib/trailblazer/developer.rb +0 -3
- data/trailblazer-developer.gemspec +1 -2
- metadata +7 -29
- data/lib/trailblazer/developer/client.rb +0 -95
- data/lib/trailblazer/developer/generate.rb +0 -98
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fabb29823b1f8422ec156cc7b8fc2878aef438281457fcaf0040dccf9cd179ed
|
|
4
|
+
data.tar.gz: dfe238f09fcd0635268ecc47112f50c99134d0a8435fd38321cf6d6de1625da8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d35b2029fb0165b313ef78505a356e0a3549f49fa311e52a2f4c32ae7dbba3d976b404e2d5293bbf9e55aed83d88efd57be6f0176affcfa64af9b0b93ae5f123
|
|
7
|
+
data.tar.gz: 2cc21b452b8ddd2b72338c854938f548b952dd8ab4fef59e83387194bc18cab8311593d6bce747cff34f70ed92ddde73d501154882edaa6a35d372c9818a0536
|
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
|
@@ -7,6 +7,3 @@ gemspec
|
|
|
7
7
|
# gem "trailblazer-activity", path: "../trailblazer-activity"
|
|
8
8
|
# gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
|
9
9
|
# gem "trailblazer-activity-dsl-linear", github: "trailblazer/trailblazer-activity-dsl-linear"
|
|
10
|
-
|
|
11
|
-
gem "faraday"
|
|
12
|
-
gem "multi_json"
|
|
@@ -12,8 +12,5 @@ require "trailblazer/developer/trace"
|
|
|
12
12
|
require "trailblazer/developer/trace/present"
|
|
13
13
|
require "trailblazer/developer/trace/focusable"
|
|
14
14
|
require "trailblazer/developer/trace/inspector"
|
|
15
|
-
require "trailblazer/developer/generate"
|
|
16
15
|
require "trailblazer/developer/render/circuit"
|
|
17
16
|
require "trailblazer/developer/render/linear"
|
|
18
|
-
|
|
19
|
-
# require "trailblazer/developer/client"
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ["apotonick@gmail.com"]
|
|
10
10
|
|
|
11
11
|
spec.summary = "Developer tools for Trailblazer."
|
|
12
|
-
spec.description = "Developer tools for Trailblazer: debugger,
|
|
12
|
+
spec.description = "Developer tools for Trailblazer: debugger, activity visualizer and tracing."
|
|
13
13
|
spec.homepage = "http://trailblazer.to"
|
|
14
14
|
spec.license = "LGPL-3.0"
|
|
15
15
|
|
|
@@ -25,6 +25,5 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
|
|
26
26
|
spec.add_dependency "trailblazer-activity", ">= 0.12.2", "< 1.0.0"
|
|
27
27
|
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.4.1", "< 1.0.0"
|
|
28
|
-
spec.add_dependency "representable", ">= 3.1.1", "< 4.0.0"
|
|
29
28
|
spec.add_dependency "hirb"
|
|
30
29
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trailblazer-developer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -106,26 +106,6 @@ dependencies:
|
|
|
106
106
|
- - "<"
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
108
|
version: 1.0.0
|
|
109
|
-
- !ruby/object:Gem::Dependency
|
|
110
|
-
name: representable
|
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
|
112
|
-
requirements:
|
|
113
|
-
- - ">="
|
|
114
|
-
- !ruby/object:Gem::Version
|
|
115
|
-
version: 3.1.1
|
|
116
|
-
- - "<"
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: 4.0.0
|
|
119
|
-
type: :runtime
|
|
120
|
-
prerelease: false
|
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
-
requirements:
|
|
123
|
-
- - ">="
|
|
124
|
-
- !ruby/object:Gem::Version
|
|
125
|
-
version: 3.1.1
|
|
126
|
-
- - "<"
|
|
127
|
-
- !ruby/object:Gem::Version
|
|
128
|
-
version: 4.0.0
|
|
129
109
|
- !ruby/object:Gem::Dependency
|
|
130
110
|
name: hirb
|
|
131
111
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,7 +120,7 @@ dependencies:
|
|
|
140
120
|
- - ">="
|
|
141
121
|
- !ruby/object:Gem::Version
|
|
142
122
|
version: '0'
|
|
143
|
-
description: 'Developer tools for Trailblazer: debugger,
|
|
123
|
+
description: 'Developer tools for Trailblazer: debugger, activity visualizer and tracing.'
|
|
144
124
|
email:
|
|
145
125
|
- apotonick@gmail.com
|
|
146
126
|
executables: []
|
|
@@ -158,8 +138,6 @@ files:
|
|
|
158
138
|
- bin/setup
|
|
159
139
|
- gems.local.rb
|
|
160
140
|
- lib/trailblazer/developer.rb
|
|
161
|
-
- lib/trailblazer/developer/client.rb
|
|
162
|
-
- lib/trailblazer/developer/generate.rb
|
|
163
141
|
- lib/trailblazer/developer/render/circuit.rb
|
|
164
142
|
- lib/trailblazer/developer/render/linear.rb
|
|
165
143
|
- lib/trailblazer/developer/trace.rb
|
|
@@ -175,7 +153,7 @@ homepage: http://trailblazer.to
|
|
|
175
153
|
licenses:
|
|
176
154
|
- LGPL-3.0
|
|
177
155
|
metadata: {}
|
|
178
|
-
post_install_message:
|
|
156
|
+
post_install_message:
|
|
179
157
|
rdoc_options: []
|
|
180
158
|
require_paths:
|
|
181
159
|
- lib
|
|
@@ -190,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
190
168
|
- !ruby/object:Gem::Version
|
|
191
169
|
version: '0'
|
|
192
170
|
requirements: []
|
|
193
|
-
rubygems_version: 3.
|
|
194
|
-
signing_key:
|
|
171
|
+
rubygems_version: 3.2.3
|
|
172
|
+
signing_key:
|
|
195
173
|
specification_version: 4
|
|
196
174
|
summary: Developer tools for Trailblazer.
|
|
197
175
|
test_files: []
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
require "faraday"
|
|
2
|
-
require "base64"
|
|
3
|
-
require "json"
|
|
4
|
-
require "representable/json"
|
|
5
|
-
|
|
6
|
-
module Trailblazer::Developer
|
|
7
|
-
module Client
|
|
8
|
-
Diagram = Struct.new(:id, :body)
|
|
9
|
-
|
|
10
|
-
class Diagram::Representer < Representable::Decorator
|
|
11
|
-
include Representable::JSON
|
|
12
|
-
property :id
|
|
13
|
-
property :body, as: :diagram
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
module_function
|
|
17
|
-
|
|
18
|
-
def Diagram(id, body)
|
|
19
|
-
Diagram.new(id, body).freeze
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def import(id:, query:"", **options)
|
|
23
|
-
token = retrieve_token(**options)
|
|
24
|
-
export_diagram(id: id, token: token, query: query, **options)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def retrieve_token(email:, api_key:, url: "/signin", **options)
|
|
28
|
-
body = JSON.generate({email: email, api_key: api_key})
|
|
29
|
-
|
|
30
|
-
response = request(token: nil, method: :get, url: url, body: body, **options)
|
|
31
|
-
return false unless response.status == 200
|
|
32
|
-
|
|
33
|
-
# token = CGI::Cookie.parse(response.headers["set-cookie"])["token"][0]
|
|
34
|
-
JSON.parse(response.body)["token"]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def export_diagram(id:, query:, **options)
|
|
38
|
-
response = request(body: nil, url: "/api/v1/diagrams/#{id}/export#{query}", method: :get, **options)
|
|
39
|
-
|
|
40
|
-
# parse_response(response)
|
|
41
|
-
response.body
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def duplicate(id:, **options)
|
|
45
|
-
token = retrieve_token(**options)
|
|
46
|
-
|
|
47
|
-
response = request(body: nil, token: token, url: "/api/v1/diagrams/#{id}/duplicate", method: :get, **options)
|
|
48
|
-
parse_response(response)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# DISCUSS: do we need that?
|
|
52
|
-
def new_diagram(token:, **options)
|
|
53
|
-
response = request(body: nil, url: "/api/v1/diagrams/new", method: :get, token: token, **options)
|
|
54
|
-
|
|
55
|
-
# TODO: use Dry::Struct
|
|
56
|
-
# TODO: handle unauthorized/errors
|
|
57
|
-
parse_response(response)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def request(host:, url:, method:, token:, body:, **)
|
|
61
|
-
conn = Faraday.new(url: host)
|
|
62
|
-
|
|
63
|
-
conn.send(method) do |req|
|
|
64
|
-
req.url url
|
|
65
|
-
req.headers["Content-Type"] = "application/json"
|
|
66
|
-
req.body = body
|
|
67
|
-
req.headers["Authorization"] = token
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def parse_response(response)
|
|
72
|
-
diagram = Diagram.new
|
|
73
|
-
Diagram::Representer.new(diagram).from_json(response.body) # a parsed hash would be cooler?
|
|
74
|
-
|
|
75
|
-
diagram
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# TODO: remove me!
|
|
79
|
-
def self.push(operation:, name:)
|
|
80
|
-
xml = Trailblazer::Diagram::BPMN.to_xml(operation["__activity__"], operation["__sequence__"].map(&:id))
|
|
81
|
-
token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJpZCI6MywidXNlcm5hbWUiOiJhcG90b25pY2siLCJlbWFpbCI6Im5pY2tAdHJhaWxibGF6ZXIudG8ifQ." # rubocop:disable Metrics/LineLength
|
|
82
|
-
conn = Faraday.new(url: "https://api.trb.to")
|
|
83
|
-
response = conn.post do |req|
|
|
84
|
-
req.url "/dev/v1/import"
|
|
85
|
-
req.headers["Content-Type"] = "application/json"
|
|
86
|
-
req.headers["Authorization"] = token
|
|
87
|
-
require "base64"
|
|
88
|
-
|
|
89
|
-
req.body = %({ "name": "#{name}", "xml":"#{Base64.strict_encode64(xml)}" })
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
puts response.status.inspect
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
require "representable/hash"
|
|
2
|
-
require "trailblazer/activity/dsl/linear" # Railway.
|
|
3
|
-
|
|
4
|
-
module Trailblazer
|
|
5
|
-
module Developer
|
|
6
|
-
# Computes an {Intermediate} data structure from a TRB-editor.js file.
|
|
7
|
-
module Generate
|
|
8
|
-
module_function
|
|
9
|
-
|
|
10
|
-
Element = Struct.new(:id, :type, :linksTo, :data, :label, :parent)
|
|
11
|
-
Arrow = Struct.new(:target, :label, :message, :target_lane)
|
|
12
|
-
|
|
13
|
-
module Representer
|
|
14
|
-
class Activity < Representable::Decorator
|
|
15
|
-
include Representable::Hash
|
|
16
|
-
|
|
17
|
-
collection :elements, class: Element do
|
|
18
|
-
property :id
|
|
19
|
-
property :type
|
|
20
|
-
collection :linksTo, class: Arrow, default: ::Declarative::Variables::Append([]) do
|
|
21
|
-
property :target
|
|
22
|
-
property :label
|
|
23
|
-
property :message
|
|
24
|
-
property :target_lane
|
|
25
|
-
end
|
|
26
|
-
property :data, default: {}
|
|
27
|
-
|
|
28
|
-
property :label
|
|
29
|
-
property :parent # TODO: remove?
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def call(hash)
|
|
35
|
-
_, (ctx, _) = Activity::TaskWrap.invoke(Pipeline, [{hash: hash}, {}])
|
|
36
|
-
ctx[:intermediate]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def transform_from_hash(ctx, hash:, parser: Representer::Activity, **)
|
|
40
|
-
ctx[:elements] = parser.new(OpenStruct.new).from_hash(hash).elements
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def find_start_events(ctx, elements:, **)
|
|
44
|
-
ctx[:start_events] = elements.find_all { |el| el.type == "Event" }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def compute_intermediate(ctx, elements:, start_events:, **)
|
|
48
|
-
end_events = elements.find_all { |el| el.type == "EndEventTerminate" } # DISCUSS: is it really called TERMINATE?
|
|
49
|
-
|
|
50
|
-
inter = Activity::Schema::Intermediate
|
|
51
|
-
|
|
52
|
-
wiring = elements.collect { |el|
|
|
53
|
-
data = data_for(el)
|
|
54
|
-
|
|
55
|
-
[inter.TaskRef(el.id, data), el.linksTo.collect { |arrow| inter.Out(semantic_for(**arrow.to_h), arrow.target) } ] }
|
|
56
|
-
wiring = Hash[wiring]
|
|
57
|
-
|
|
58
|
-
# end events need this stupid special handling
|
|
59
|
-
# DISCUSS: currently, the END-SEMANTIC is read from the event's label.
|
|
60
|
-
wiring = wiring.merge(Hash[
|
|
61
|
-
end_events.collect do |_end|
|
|
62
|
-
ref, = wiring.find { |ref, _| ref.id == _end.id }
|
|
63
|
-
|
|
64
|
-
[ref, [inter.Out(semantic_for(**_end.to_h)|| raise, nil)]] # TODO: test the raise, happens when the semantic of an End can't be distinguished. # TODO: don't extract semantic from :label but from :data.
|
|
65
|
-
end
|
|
66
|
-
])
|
|
67
|
-
# pp wiring
|
|
68
|
-
|
|
69
|
-
ctx[:intermediate] = inter.new(wiring, end_events.collect(&:id), start_events.collect(&:id))
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# private
|
|
73
|
-
|
|
74
|
-
def data_for(element)
|
|
75
|
-
{type: element.type}.merge(element.data)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# We currently use the {:label} field of an arrow to encode an output semantic.
|
|
79
|
-
# The {:symbol_style} part will be filtered out as semantic. Defaults to {:success}.
|
|
80
|
-
def semantic_for(label:nil, **)
|
|
81
|
-
return :success unless label
|
|
82
|
-
|
|
83
|
-
extract_semantic(label)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def extract_semantic(label)
|
|
87
|
-
label.to_sym
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
class Pipeline < Trailblazer::Activity::Railway
|
|
91
|
-
step Generate.method(:transform_from_hash), id: :transform_from_hash
|
|
92
|
-
step Generate.method(:find_start_events), id: :find_start_events
|
|
93
|
-
step Generate.method(:compute_intermediate), id: :compute_intermediate
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
# [Inter::Out(:success, nil)]
|