isomorfeus-data 1.0.0.zeta12 → 1.0.0.zeta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/isomorfeus-data.rb +2 -0
- data/lib/isomorfeus/data/attribute_support.rb +2 -2
- data/lib/isomorfeus/data/config.rb +1 -1
- data/lib/isomorfeus/data/element_validator.rb +16 -16
- data/lib/isomorfeus/data/generic_class_api.rb +34 -52
- data/lib/isomorfeus/data/generic_instance_api.rb +35 -8
- data/lib/isomorfeus/data/handler/arango.rb +2 -3
- data/lib/isomorfeus/data/handler/generic.rb +44 -55
- data/lib/isomorfeus/data/handler/object_call.rb +2 -3
- data/lib/isomorfeus/data/handler/object_store.rb +2 -3
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus_data/lucid_data/array/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/array/mixin.rb +18 -22
- data/lib/isomorfeus_data/lucid_data/collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/collection/mixin.rb +33 -36
- data/lib/isomorfeus_data/lucid_data/composition/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/composition/mixin.rb +35 -29
- data/lib/isomorfeus_data/lucid_data/document/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge/mixin.rb +39 -31
- data/lib/isomorfeus_data/lucid_data/edge_collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge_collection/mixin.rb +33 -29
- data/lib/isomorfeus_data/lucid_data/graph/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/graph/mixin.rb +41 -40
- data/lib/isomorfeus_data/lucid_data/hash/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/hash/mixin.rb +20 -25
- data/lib/isomorfeus_data/lucid_data/link/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/link_collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/node/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/node/mixin.rb +18 -23
- data/lib/isomorfeus_data/lucid_data/query/base.rb +13 -0
- data/lib/isomorfeus_data/lucid_data/query/mixin.rb +88 -0
- data/lib/isomorfeus_data/lucid_data/query_result.rb +12 -10
- data/lib/isomorfeus_data/lucid_data/vertex/base.rb +0 -2
- data/lib/lucid_arango/collection/base.rb +0 -2
- data/lib/lucid_arango/collection/mixin.rb +0 -2
- data/lib/lucid_arango/document/base.rb +0 -2
- data/lib/lucid_arango/edge/base.rb +0 -3
- data/lib/lucid_arango/edge/mixin.rb +0 -2
- data/lib/lucid_arango/edge_collection/base.rb +0 -2
- data/lib/lucid_arango/edge_collection/mixin.rb +0 -2
- data/lib/lucid_arango/graph/base.rb +0 -2
- data/lib/lucid_arango/graph/mixin.rb +0 -2
- data/lib/lucid_arango/node/base.rb +0 -3
- data/lib/lucid_arango/node/mixin.rb +0 -2
- data/lib/lucid_arango/object/base.rb +0 -2
- data/lib/lucid_arango/object/mixin.rb +1 -3
- data/lib/lucid_arango/remote_object/base.rb +0 -2
- data/lib/lucid_arango/remote_object/mixin.rb +0 -2
- data/lib/lucid_arango/vertex/base.rb +0 -2
- metadata +10 -8
@@ -0,0 +1,88 @@
|
|
1
|
+
module LucidData
|
2
|
+
module Query
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(LucidPropDeclaration::Mixin)
|
6
|
+
|
7
|
+
if RUBY_ENGINE == 'opal'
|
8
|
+
base.instance_exec do
|
9
|
+
def execute(props:)
|
10
|
+
query_result_instance = LucidData::QueryResult.new
|
11
|
+
promise_execute(props: props, query_result_instance: query_result_instance) unless query_result_instance.loaded?
|
12
|
+
query_result_instance
|
13
|
+
end
|
14
|
+
|
15
|
+
def promise_execute(props:, query_result_instance: nil)
|
16
|
+
query_result_instance = LucidData::QueryResult.new unless query_result_instance
|
17
|
+
props.each_key do |prop_name|
|
18
|
+
Isomorfeus.raise_error(message: "#{self.to_s} No such query prop declared: '#{prop_name}'!") unless declared_props.key?(prop_name)
|
19
|
+
end
|
20
|
+
validate_props(props)
|
21
|
+
data_props = { props: props, query_result_instance_key: query_result_instance.key }
|
22
|
+
props_json = data_props.to_json
|
23
|
+
Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :execute, props_json).then do |agent|
|
24
|
+
if agent.processed
|
25
|
+
agent.result
|
26
|
+
else
|
27
|
+
agent.processed = true
|
28
|
+
if agent.response.key?(:error)
|
29
|
+
`console.error(#{agent.response[:error].to_n})`
|
30
|
+
Isomorfeus.raise_error(message: agent.response[:error])
|
31
|
+
end
|
32
|
+
query_result_instance._load_from_store!
|
33
|
+
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.full_response[:data])
|
34
|
+
agent.result = query_result_instance
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute_query(_); end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
unless base == LucidData::Node::Base || base == LucidData::Document::Base || base == LucidData::Vertex::Base
|
43
|
+
Isomorfeus.add_valid_data_class(base)
|
44
|
+
end
|
45
|
+
|
46
|
+
base.instance_exec do
|
47
|
+
def promise_execute(props:)
|
48
|
+
instance = self.execute(props: props)
|
49
|
+
result_promise = Promise.new
|
50
|
+
result_promise.resolve(instance)
|
51
|
+
result_promise
|
52
|
+
end
|
53
|
+
|
54
|
+
def execute(props:, query_result_instance_key: nil)
|
55
|
+
props.each_key do |prop_name|
|
56
|
+
Isomorfeus.raise_error(message: "#{self.to_s} No such query prop declared: '#{prop_name}'!") unless declared_props.key?(prop_name)
|
57
|
+
end
|
58
|
+
validate_props(props)
|
59
|
+
query_result = LucidData::QueryResult.new(key: query_result_instance_key)
|
60
|
+
query_result.result_set = instance_exec(props: Isomorfeus::PropsProxy.new(props), &@_query_block)
|
61
|
+
query_result
|
62
|
+
end
|
63
|
+
|
64
|
+
def execute_query(&block)
|
65
|
+
@_query_block = block
|
66
|
+
end
|
67
|
+
|
68
|
+
def current_user
|
69
|
+
Isomorfeus.current_user
|
70
|
+
end
|
71
|
+
|
72
|
+
def pub_sub_client
|
73
|
+
Isomorfeus.pub_sub_client
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def current_user
|
78
|
+
Isomorfeus.current_user
|
79
|
+
end
|
80
|
+
|
81
|
+
def pub_sub_client
|
82
|
+
Isomorfeus.pub_sub_client
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -18,14 +18,15 @@ module LucidData
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def loaded?
|
21
|
-
Redux.fetch_by_path(
|
21
|
+
Redux.fetch_by_path(:data_state, @class_name, @key) ? true : false
|
22
22
|
end
|
23
23
|
|
24
24
|
def key?(k)
|
25
|
-
if @result_set
|
25
|
+
if @result_set
|
26
26
|
@result_set.key?(k)
|
27
27
|
else
|
28
|
-
stored_results = Redux.fetch_by_path(
|
28
|
+
stored_results = Redux.fetch_by_path(:data_state, @class_name, @key)
|
29
|
+
return false unless stored_results
|
29
30
|
`Object.hasOwnProperty(stored_results, k)`
|
30
31
|
end
|
31
32
|
end
|
@@ -36,20 +37,21 @@ module LucidData
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def method_missing(accessor_name, *args, &block)
|
39
|
-
|
40
|
-
sid = if @result_set.any?
|
40
|
+
sid = if @result_set
|
41
41
|
@result_set[accessor_name]
|
42
42
|
else
|
43
|
-
stored_results = Redux.fetch_by_path(
|
44
|
-
stored_results.JS[accessor_name]
|
43
|
+
stored_results = Redux.fetch_by_path(:data_state, @class_name, @key)
|
44
|
+
stored_results.JS[accessor_name] if stored_results
|
45
45
|
end
|
46
|
+
Isomorfeus.raise_error(message: "#{@class_name}: no such thing '#{accessor_name}' in the results!") unless sid
|
46
47
|
Isomorfeus.instance_from_sid(sid)
|
47
48
|
end
|
48
49
|
else
|
49
50
|
def initialize(key: nil, result_set: {})
|
50
51
|
@class_name = 'LucidData::QueryResult'
|
51
52
|
@key = key ? key.to_s : self.object_id.to_s
|
52
|
-
@result_set = result_set
|
53
|
+
@result_set = result_set.nil? ? {} : result_set
|
54
|
+
@result_set.transform_keys!(&:to_sym)
|
53
55
|
end
|
54
56
|
|
55
57
|
def loaded?
|
@@ -66,14 +68,14 @@ module LucidData
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def method_missing(accessor_name, *args, &block)
|
69
|
-
|
71
|
+
Isomorfeus.raise_error(message: "#{@class_name}: no such thing '#{accessor_name}' in the results!") unless @result_set.key?(accessor_name)
|
70
72
|
@result_set[accessor_name]
|
71
73
|
end
|
72
74
|
|
73
75
|
def to_transport
|
74
76
|
sids_hash = {}
|
75
77
|
@result_set.each do |key, value|
|
76
|
-
sids_hash[key] = value.to_sid
|
78
|
+
sids_hash[key.to_s] = value.to_sid
|
77
79
|
end
|
78
80
|
{ @class_name => { @key => sids_hash }}
|
79
81
|
end
|
@@ -80,7 +80,7 @@ module LucidStorableObject
|
|
80
80
|
agent.processed = true
|
81
81
|
if agent.response.key?(:error)
|
82
82
|
`console.error(#{agent.response[:error].to_n})`
|
83
|
-
|
83
|
+
Isomorfeus.raise_error(message: agent.response[:error])
|
84
84
|
end
|
85
85
|
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.full_response[:data])
|
86
86
|
agent.result = instance
|
@@ -93,8 +93,6 @@ module LucidStorableObject
|
|
93
93
|
else # RUBY_ENGINE
|
94
94
|
unless base == LucidStorableObject::Base
|
95
95
|
Isomorfeus.add_valid_data_class(base)
|
96
|
-
base.prop :pub_sub_client, default: nil
|
97
|
-
base.prop :current_user, default: Anonymous.new
|
98
96
|
end
|
99
97
|
|
100
98
|
def initialize(store_path: nil, validated_props: nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.zeta13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 16.12.
|
89
|
+
version: 16.12.14
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 16.12.
|
96
|
+
version: 16.12.14
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-redux
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.0.0.
|
117
|
+
version: 1.0.0.zeta13
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.0.0.
|
124
|
+
version: 1.0.0.zeta13
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: isomorfeus
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0.
|
131
|
+
version: 1.0.0.zeta13
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.0.0.
|
138
|
+
version: 1.0.0.zeta13
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: opal-webpack-loader
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,6 +228,8 @@ files:
|
|
228
228
|
- lib/isomorfeus_data/lucid_data/link_collection/mixin.rb
|
229
229
|
- lib/isomorfeus_data/lucid_data/node/base.rb
|
230
230
|
- lib/isomorfeus_data/lucid_data/node/mixin.rb
|
231
|
+
- lib/isomorfeus_data/lucid_data/query/base.rb
|
232
|
+
- lib/isomorfeus_data/lucid_data/query/mixin.rb
|
231
233
|
- lib/isomorfeus_data/lucid_data/query_result.rb
|
232
234
|
- lib/isomorfeus_data/lucid_data/vertex/base.rb
|
233
235
|
- lib/isomorfeus_data/lucid_data/vertex/mixin.rb
|