ruby_event_store-browser 2.16.0 → 2.17.0
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/ruby_event_store/browser/app.rb +10 -29
- data/lib/ruby_event_store/browser/gem_source.rb +1 -3
- data/lib/ruby_event_store/browser/get_event.rb +4 -8
- data/lib/ruby_event_store/browser/get_events_from_stream.rb +6 -25
- data/lib/ruby_event_store/browser/get_stream.rb +2 -11
- data/lib/ruby_event_store/browser/json_api_event.rb +5 -13
- data/lib/ruby_event_store/browser/json_api_stream.rb +5 -5
- data/lib/ruby_event_store/browser/router.rb +2 -13
- data/lib/ruby_event_store/browser/urls.rb +4 -18
- data/lib/ruby_event_store/browser/version.rb +1 -1
- data/public/ruby_event_store_browser.js +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 411db34f9c7c3ce4b067a4124b698fa9233519c46f88a00dfc3f9d93abf6acc2
|
4
|
+
data.tar.gz: 43ae46352611d324fcfce9c37e6a5ed7d9b6b6dd45077345c147c2c46c4460a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef46e9fbd66fd0a0c6d763c2ff65cf088987c4a60630892c862a85794a881190917e7635d9a68a4785e85e776bddf1436733d75be5e181605135b06c757d4505
|
7
|
+
data.tar.gz: 4afc2c53bbdf82042cf33e89a42ad1fb9f5bd20ce37b4e7db5053bfa2dd5308b2e085f015722fc12ec541b88d20179bd94463e9da156662fdb4a55b2f4491e74
|
@@ -64,18 +64,12 @@ module RubyEventStore
|
|
64
64
|
related_streams_query: related_streams_query,
|
65
65
|
host: host,
|
66
66
|
root_path: path,
|
67
|
-
api_url: api_url
|
67
|
+
api_url: api_url,
|
68
68
|
)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
def initialize(
|
73
|
-
event_store_locator:,
|
74
|
-
related_streams_query:,
|
75
|
-
host:,
|
76
|
-
root_path:,
|
77
|
-
api_url:
|
78
|
-
)
|
72
|
+
def initialize(event_store_locator:, related_streams_query:, host:, root_path:, api_url:)
|
79
73
|
@event_store_locator = event_store_locator
|
80
74
|
@related_streams_query = related_streams_query
|
81
75
|
@routing = Urls.from_configuration(host, root_path, api_url)
|
@@ -84,27 +78,21 @@ module RubyEventStore
|
|
84
78
|
def call(env)
|
85
79
|
router = Router.new(routing)
|
86
80
|
router.add_route("GET", "/api/events/:event_id") do |params|
|
87
|
-
json GetEvent.new(
|
88
|
-
event_store: event_store,
|
89
|
-
event_id: params.fetch("event_id")
|
90
|
-
)
|
81
|
+
json GetEvent.new(event_store: event_store, event_id: params.fetch("event_id"))
|
91
82
|
end
|
92
83
|
router.add_route("GET", "/api/streams/:stream_name") do |params, urls|
|
93
84
|
json GetStream.new(
|
94
85
|
stream_name: params.fetch("stream_name"),
|
95
86
|
routing: urls,
|
96
|
-
related_streams_query: related_streams_query
|
87
|
+
related_streams_query: related_streams_query,
|
97
88
|
)
|
98
89
|
end
|
99
|
-
router.add_route(
|
100
|
-
"GET",
|
101
|
-
"/api/streams/:stream_name/relationships/events"
|
102
|
-
) do |params, urls|
|
90
|
+
router.add_route("GET", "/api/streams/:stream_name/relationships/events") do |params, urls|
|
103
91
|
json GetEventsFromStream.new(
|
104
92
|
event_store: event_store,
|
105
93
|
routing: urls,
|
106
94
|
stream_name: params.fetch("stream_name"),
|
107
|
-
page: params["page"]
|
95
|
+
page: params["page"],
|
108
96
|
)
|
109
97
|
end
|
110
98
|
|
@@ -117,7 +105,7 @@ module RubyEventStore
|
|
117
105
|
initial_data: {
|
118
106
|
rootUrl: urls.app_url,
|
119
107
|
apiUrl: urls.api_url,
|
120
|
-
resVersion: res_version
|
108
|
+
resVersion: res_version,
|
121
109
|
}
|
122
110
|
end
|
123
111
|
end
|
@@ -142,6 +130,7 @@ module RubyEventStore
|
|
142
130
|
<title>RubyEventStore::Browser</title>
|
143
131
|
<link type="text/css" rel="stylesheet" href="<%= browser_css_src %>">
|
144
132
|
<meta name="ruby-event-store-browser-settings" content="<%= Rack::Utils.escape_html(JSON.dump(initial_data)) %>">
|
133
|
+
<meta name="robots" content="noindex, nofollow">
|
145
134
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
146
135
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
147
136
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
@@ -162,19 +151,11 @@ module RubyEventStore
|
|
162
151
|
end
|
163
152
|
|
164
153
|
def json(body)
|
165
|
-
[
|
166
|
-
200,
|
167
|
-
{ "content-type" => "application/vnd.api+json" },
|
168
|
-
[JSON.dump(body.to_h)]
|
169
|
-
]
|
154
|
+
[200, { "content-type" => "application/vnd.api+json" }, [JSON.dump(body.to_h)]]
|
170
155
|
end
|
171
156
|
|
172
157
|
def erb(template, **locals)
|
173
|
-
[
|
174
|
-
200,
|
175
|
-
{ "content-type" => "text/html;charset=utf-8" },
|
176
|
-
[ERB.new(template).result_with_hash(locals)]
|
177
|
-
]
|
158
|
+
[200, { "content-type" => "text/html;charset=utf-8" }, [ERB.new(template).result_with_hash(locals)]]
|
178
159
|
end
|
179
160
|
|
180
161
|
def res_version
|
@@ -9,9 +9,7 @@ module RubyEventStore
|
|
9
9
|
@path =
|
10
10
|
load_path
|
11
11
|
.select { |entry| String === entry }
|
12
|
-
.find
|
13
|
-
entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z}
|
14
|
-
end
|
12
|
+
.find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z} }
|
15
13
|
end
|
16
14
|
|
17
15
|
def version
|
@@ -12,17 +12,15 @@ module RubyEventStore
|
|
12
12
|
{
|
13
13
|
data: [
|
14
14
|
JsonApiEvent.new(event, parent_event_id).to_h,
|
15
|
-
{ relationships: { streams: { data: streams } } }
|
16
|
-
].reduce(&:merge)
|
15
|
+
{ relationships: { streams: { data: streams } } },
|
16
|
+
].reduce(&:merge),
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def streams
|
23
|
-
event_store
|
24
|
-
.streams_of(event_id)
|
25
|
-
.map { |stream| { "id" => stream.name, "type" => "streams" } }
|
23
|
+
event_store.streams_of(event_id).map { |stream| { "id" => stream.name, "type" => "streams" } }
|
26
24
|
end
|
27
25
|
|
28
26
|
attr_reader :event_store, :event_id
|
@@ -32,9 +30,7 @@ module RubyEventStore
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def parent_event_id
|
35
|
-
if event.metadata.has_key?(:causation_id)
|
36
|
-
event_store.read.event(event.metadata.fetch(:causation_id))&.event_id
|
37
|
-
end
|
33
|
+
event_store.read.event(event.metadata.fetch(:causation_id))&.event_id if event.metadata.has_key?(:causation_id)
|
38
34
|
end
|
39
35
|
end
|
40
36
|
end
|
@@ -47,18 +47,14 @@ module RubyEventStore
|
|
47
47
|
|
48
48
|
def events_forward(position)
|
49
49
|
spec = event_store.read.limit(count)
|
50
|
-
spec = spec.stream(stream_name) unless stream_name.eql?(
|
51
|
-
SERIALIZED_GLOBAL_STREAM_NAME
|
52
|
-
)
|
50
|
+
spec = spec.stream(stream_name) unless stream_name.eql?(SERIALIZED_GLOBAL_STREAM_NAME)
|
53
51
|
spec = spec.from(position) unless position.equal?(HEAD)
|
54
52
|
spec.to_a
|
55
53
|
end
|
56
54
|
|
57
55
|
def events_backward(position)
|
58
56
|
spec = event_store.read.limit(count).backward
|
59
|
-
spec = spec.stream(stream_name) unless stream_name.eql?(
|
60
|
-
SERIALIZED_GLOBAL_STREAM_NAME
|
61
|
-
)
|
57
|
+
spec = spec.stream(stream_name) unless stream_name.eql?(SERIALIZED_GLOBAL_STREAM_NAME)
|
62
58
|
spec = spec.from(position) unless position.equal?(HEAD)
|
63
59
|
spec.to_a
|
64
60
|
end
|
@@ -74,12 +70,7 @@ module RubyEventStore
|
|
74
70
|
end
|
75
71
|
|
76
72
|
def prev_page_link(event_id)
|
77
|
-
routing.paginated_events_from_stream_url(
|
78
|
-
id: stream_name,
|
79
|
-
position: event_id,
|
80
|
-
direction: :forward,
|
81
|
-
count: count
|
82
|
-
)
|
73
|
+
routing.paginated_events_from_stream_url(id: stream_name, position: event_id, direction: :forward, count: count)
|
83
74
|
end
|
84
75
|
|
85
76
|
def next_page_link(event_id)
|
@@ -87,26 +78,16 @@ module RubyEventStore
|
|
87
78
|
id: stream_name,
|
88
79
|
position: event_id,
|
89
80
|
direction: :backward,
|
90
|
-
count: count
|
81
|
+
count: count,
|
91
82
|
)
|
92
83
|
end
|
93
84
|
|
94
85
|
def first_page_link
|
95
|
-
routing.paginated_events_from_stream_url(
|
96
|
-
id: stream_name,
|
97
|
-
position: :head,
|
98
|
-
direction: :backward,
|
99
|
-
count: count
|
100
|
-
)
|
86
|
+
routing.paginated_events_from_stream_url(id: stream_name, position: :head, direction: :backward, count: count)
|
101
87
|
end
|
102
88
|
|
103
89
|
def last_page_link
|
104
|
-
routing.paginated_events_from_stream_url(
|
105
|
-
id: stream_name,
|
106
|
-
position: :head,
|
107
|
-
direction: :forward,
|
108
|
-
count: count
|
109
|
-
)
|
90
|
+
routing.paginated_events_from_stream_url(id: stream_name, position: :head, direction: :forward, count: count)
|
110
91
|
end
|
111
92
|
|
112
93
|
def count
|
@@ -10,14 +10,7 @@ module RubyEventStore
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_h
|
13
|
-
{
|
14
|
-
data:
|
15
|
-
JsonApiStream.new(
|
16
|
-
stream_name,
|
17
|
-
events_from_stream_url,
|
18
|
-
related_streams
|
19
|
-
).to_h
|
20
|
-
}
|
13
|
+
{ data: JsonApiStream.new(stream_name, events_from_stream_url, related_streams).to_h }
|
21
14
|
end
|
22
15
|
|
23
16
|
private
|
@@ -29,9 +22,7 @@ module RubyEventStore
|
|
29
22
|
end
|
30
23
|
|
31
24
|
def related_streams
|
32
|
-
unless related_streams_query.equal?(DEFAULT_RELATED_STREAMS_QUERY)
|
33
|
-
related_streams_query.call(stream_name)
|
34
|
-
end
|
25
|
+
related_streams_query.call(stream_name) unless related_streams_query.equal?(DEFAULT_RELATED_STREAMS_QUERY)
|
35
26
|
end
|
36
27
|
end
|
37
28
|
end
|
@@ -19,8 +19,8 @@ module RubyEventStore
|
|
19
19
|
correlation_stream_name: correlation_stream_name,
|
20
20
|
causation_stream_name: causation_stream_name,
|
21
21
|
type_stream_name: type_stream_name,
|
22
|
-
parent_event_id: parent_event_id
|
23
|
-
}
|
22
|
+
parent_event_id: parent_event_id,
|
23
|
+
},
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
@@ -45,21 +45,13 @@ module RubyEventStore
|
|
45
45
|
|
46
46
|
def metadata
|
47
47
|
event.metadata.to_h.tap do |m|
|
48
|
-
m[:timestamp] = event
|
49
|
-
|
50
|
-
.fetch(:timestamp)
|
51
|
-
.iso8601(TIMESTAMP_PRECISION)
|
52
|
-
m[:valid_at] = event
|
53
|
-
.metadata
|
54
|
-
.fetch(:valid_at)
|
55
|
-
.iso8601(TIMESTAMP_PRECISION)
|
48
|
+
m[:timestamp] = event.metadata.fetch(:timestamp).iso8601(TIMESTAMP_PRECISION)
|
49
|
+
m[:valid_at] = event.metadata.fetch(:valid_at).iso8601(TIMESTAMP_PRECISION)
|
56
50
|
end
|
57
51
|
end
|
58
52
|
|
59
53
|
def correlation_stream_name
|
60
|
-
if metadata.has_key?(:correlation_id)
|
61
|
-
"$by_correlation_id_#{metadata.fetch(:correlation_id)}"
|
62
|
-
end
|
54
|
+
"$by_correlation_id_#{metadata.fetch(:correlation_id)}" if metadata.has_key?(:correlation_id)
|
63
55
|
end
|
64
56
|
|
65
57
|
def causation_stream_name
|
@@ -14,15 +14,15 @@ module RubyEventStore
|
|
14
14
|
id: stream_name,
|
15
15
|
type: "streams",
|
16
16
|
attributes: {
|
17
|
-
related_streams: related_streams
|
17
|
+
related_streams: related_streams,
|
18
18
|
},
|
19
19
|
relationships: {
|
20
20
|
events: {
|
21
21
|
links: {
|
22
|
-
self: events_from_stream_url
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}
|
22
|
+
self: events_from_stream_url,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
},
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
@@ -19,11 +19,7 @@ module RubyEventStore
|
|
19
19
|
return unless request.request_method.eql?(request_method)
|
20
20
|
|
21
21
|
match_data = regexp.match(File.join("/", request.path_info))
|
22
|
-
if match_data
|
23
|
-
match_data.named_captures.transform_values do |v|
|
24
|
-
Rack::Utils.unescape(v)
|
25
|
-
end
|
26
|
-
end
|
22
|
+
match_data.named_captures.transform_values { |v| Rack::Utils.unescape(v) } if match_data
|
27
23
|
end
|
28
24
|
|
29
25
|
def call(params, urls)
|
@@ -51,14 +47,7 @@ module RubyEventStore
|
|
51
47
|
def handle(request)
|
52
48
|
routes.each do |route|
|
53
49
|
route_params = route.match(request)
|
54
|
-
if route_params
|
55
|
-
return(
|
56
|
-
route.call(
|
57
|
-
request.params.merge(route_params),
|
58
|
-
urls.with_request(request)
|
59
|
-
)
|
60
|
-
)
|
61
|
-
end
|
50
|
+
return(route.call(request.params.merge(route_params), urls.with_request(request))) if route_params
|
62
51
|
end
|
63
52
|
raise NoMatch
|
64
53
|
end
|
@@ -12,11 +12,7 @@ module RubyEventStore
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def with_request(request)
|
15
|
-
Urls.new(
|
16
|
-
host || request.base_url,
|
17
|
-
root_path || request.script_name,
|
18
|
-
api_url
|
19
|
-
)
|
15
|
+
Urls.new(host || request.base_url, root_path || request.script_name, api_url)
|
20
16
|
end
|
21
17
|
|
22
18
|
attr_reader :app_url, :api_url, :host, :root_path
|
@@ -37,20 +33,11 @@ module RubyEventStore
|
|
37
33
|
"#{api_url}/streams"
|
38
34
|
end
|
39
35
|
|
40
|
-
def paginated_events_from_stream_url(
|
41
|
-
id:,
|
42
|
-
position: nil,
|
43
|
-
direction: nil,
|
44
|
-
count: nil
|
45
|
-
)
|
36
|
+
def paginated_events_from_stream_url(id:, position: nil, direction: nil, count: nil)
|
46
37
|
stream_name = Rack::Utils.escape(id)
|
47
38
|
query_string =
|
48
39
|
URI.encode_www_form(
|
49
|
-
{
|
50
|
-
"page[position]" => position,
|
51
|
-
"page[direction]" => direction,
|
52
|
-
"page[count]" => count
|
53
|
-
}.compact
|
40
|
+
{ "page[position]" => position, "page[direction]" => direction, "page[count]" => count }.compact,
|
54
41
|
)
|
55
42
|
|
56
43
|
if query_string.empty?
|
@@ -75,8 +62,7 @@ module RubyEventStore
|
|
75
62
|
end
|
76
63
|
|
77
64
|
def ==(o)
|
78
|
-
self.class.eql?(o.class) && app_url.eql?(o.app_url) &&
|
79
|
-
api_url.eql?(o.api_url)
|
65
|
+
self.class.eql?(o.class) && app_url.eql?(o.app_url) && api_url.eql?(o.api_url)
|
80
66
|
end
|
81
67
|
|
82
68
|
private
|