isomorfeus-data 23.8.0.rc3 → 23.9.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec5cdc77a7c38ce1effdb26513b5b2a4194df58daf8b8392e94c9fa0ae9e1420
4
- data.tar.gz: 41badde15b9fa9cb9b3ba4f2aee351a239363d1b4a6d8ddc5ee12530fbc5b20a
3
+ metadata.gz: 739662fafe5bae053feae6e3ead2d2bf9d8a63b73779fd3301327ed8de761d20
4
+ data.tar.gz: fe7c744206f046ffb0177efb1b1acb4b003841d2f1e695b86e57dd554d49dbc2
5
5
  SHA512:
6
- metadata.gz: d42ddf41c39b22d3712231e0fb470c8541ad7a91116e030f50bef58c71d2d4d3bebea654254f4f13a999864bd948f7121f8d02a0bd78f9a424a6688dae2bfad9
7
- data.tar.gz: 3f914abb6235059f3c534b96548ed1500e8f9c8e2de54ddb20bf18e0fa84a7304b09583c03367dd52c7f3ea3a6abf3b86cd8e85b44cf27068b87cfedbd2449ea
6
+ metadata.gz: 991f39d7186356302fc7bbbf67ee07f0370b418b739cb0038f6d4ad30be926daac8e281118ed7595f3e118c643f23ffea8d11c20a4dc6817befb2a446d422673
7
+ data.tar.gz: bb182834ac1435b13b2ebcd1530f365d81171097a930bcfa2d565f2f8e028278770adeb950e0dd599e06e6b25439081cfdbae283a79e7d3c789738d2be163173
@@ -15,7 +15,7 @@ module Isomorfeus
15
15
  next_enh.call(action)
16
16
  end
17
17
 
18
- FILE_ACTION_TYPES = %w[FILE_LOAD FILE_SAVE FILE_CREATE FILE_DESTROY]
18
+ FILE_ACTION_TYPES = %w[FILE_LOAD FILE_SAVE FILE_CREATE FILE_SEARCH FILE_DESTROY]
19
19
  FILE_MERGE_TYPES = %w[FILE_SAVE FILE_CREATE]
20
20
 
21
21
  CLIENT_FILE_ENHANCER = proc do |action, next_enh|
@@ -238,6 +238,35 @@ module Isomorfeus
238
238
  instance_uuid = nil
239
239
  end
240
240
  action = { type: 'DATA_ADD', data: { item_class_name => { item_key => { data_uri: data_uri, revision: revision, instance_uuid: instance_uuid }}}}
241
+ elsif action_type == 'FILE_SEARCH'
242
+ item_class_name = action[:class_name]
243
+ item_class = get_verified_class(item_class_name)
244
+ query = action[:query].to_sym
245
+ params = action[:params]
246
+ raise "Invalid params #{params}!" unless params.nil? || params.is_a?(Hash)
247
+ params.transform_keys!(&:to_sym) if params
248
+ authorization_error!(action) unless Isomorfeus.current_user.authorized?(item_class, :search, { query: query, params: params })
249
+ result = []
250
+ query_string = item_class.queries.dig(query, :query_string)
251
+ raise "Invalid query '#{query}'!" unless query_string
252
+ options = item_class.queries[query][:options] || {}
253
+ fa = item_class.file_accelerator
254
+ full_query = if params.is_a?(Hash)
255
+ if options[:escape_params]
256
+ escaped_params = params.to_h do |k,v|
257
+ [k, oa.escape(v)]
258
+ end
259
+ query_string % escaped_params
260
+ else
261
+ query_string % params
262
+ end
263
+ else
264
+ query_string
265
+ end
266
+ fa.search_each(full_query, options) do |key|
267
+ result << SID.new(item_class_name, key).to_s
268
+ end
269
+ action = { type: 'DATA_MERGE', data: { queries: { item_class_name => { query => { Oj.dump(params, mode: :strict) => { result_time: Time.now.httpdate, result: result }}}}}}
241
270
  elsif action_type == 'FILE_DESTROY'
242
271
  item_class_name = action[:class_name]
243
272
  item_key = action[:key]
@@ -36,6 +36,20 @@ module Isomorfeus
36
36
  File.exist?(path)
37
37
  end
38
38
 
39
+ def search_each(_query, _options, &block)
40
+ if block_given?
41
+ each(&block)
42
+ else
43
+ files = []
44
+ each { |file| files << file }
45
+ files
46
+ end
47
+ end
48
+
49
+ def each(&block)
50
+ internal_each(@store_path, &block)
51
+ end
52
+
39
53
  def create(sid:, data:, meta:)
40
54
  path, meta_path = check_and_prepare_paths(key: sid.key)
41
55
  File.binwrite(path, data)
@@ -76,6 +90,20 @@ module Isomorfeus
76
90
 
77
91
  private
78
92
 
93
+ def internal_each(path, &block)
94
+ Dir.each_child(path) do |entry_name|
95
+ unless entry_name.end_with?('__meta__')
96
+ new_path = File.join(path, entry_name)
97
+ key = new_path[(@store_path.size+1)..-1]
98
+ if File.file?(new_path)
99
+ block.call(key)
100
+ elsif Dir.exist?(File.join(new_path))
101
+ internal_each(new_path, &block)
102
+ end
103
+ end
104
+ end
105
+ end
106
+
79
107
  def check_and_prepare_paths(key:)
80
108
  Isomorfeus.raise_error(message: 'Invalid key (contains ".." or "\\")') if key.include?('..') || key.include?('\\')
81
109
  elements = key.split('/')
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Data
3
- VERSION = '23.8.0.rc3'
3
+ VERSION = '23.9.0.rc2'
4
4
  end
5
5
  end
@@ -18,6 +18,14 @@ class LucidDataGeneric
18
18
  def current_user
19
19
  Isomorfeus.current_user
20
20
  end
21
+
22
+ def query(name, query_string, options = nil)
23
+ queries[name] = { query_string: query_string, options: options }
24
+ end
25
+
26
+ def queries
27
+ @queries ||= {}
28
+ end
21
29
  end
22
30
 
23
31
  if RUBY_ENGINE == 'opal'
data/lib/lucid_file.rb CHANGED
@@ -12,6 +12,15 @@ class LucidFile < LucidDataGeneric
12
12
  "data:#{c};base64,#{Base64.strict_encode64(d)}"
13
13
  end
14
14
 
15
+ def search(query = :all, params = nil)
16
+ proxy_instance = LucidObject::SearchResultProxy.new(self.name, query, params)
17
+ unless proxy_instance.loaded?
18
+ Isomorfeus.something_loading!
19
+ Isomorfeus.store.deferred_dispatch(type: 'FILE_SEARCH', class_name: self.name, query: query, params: params)
20
+ end
21
+ proxy_instance
22
+ end
23
+
15
24
  def destroy(key:)
16
25
  Isomorfeus.store.deferred_dispatch(type: 'FILE_DESTROY', class_name: self.name, key: key)
17
26
  true
@@ -128,6 +137,21 @@ class LucidFile < LucidDataGeneric
128
137
  @file_accelerator ||= Isomorfeus::Data::FileAccelerator.new(self)
129
138
  end
130
139
 
140
+ def each(&block)
141
+ if block_given?
142
+ file_accelerator.each do |key|
143
+ block.call self.load(key: key)
144
+ end
145
+ else
146
+ Enumerator.new do |yielder|
147
+ file_accelerator.each do |key|
148
+ yielder << self.load(key: key)
149
+ end
150
+ end
151
+ end
152
+ end
153
+ alias to_enum each
154
+
131
155
  def exist?(key:)
132
156
  raise "Not authorized!" unless current_user.authorized?(self, :load, key: key)
133
157
  file_accelerator.exist?(sid: SID.new(self.name, key))
data/lib/lucid_object.rb CHANGED
@@ -95,6 +95,11 @@ class LucidObject < LucidDataGeneric
95
95
  proxy_instance
96
96
  end
97
97
 
98
+ def destroy(key:)
99
+ Isomorfeus.store.deferred_dispatch(type: 'DATA_DESTROY', class_name: self.name, key: key)
100
+ true
101
+ end
102
+
98
103
  def load!(key:, instance: nil)
99
104
  instance = self.new(key: key, _loading: true) unless instance
100
105
  Isomorfeus.something_loading!
@@ -102,11 +107,6 @@ class LucidObject < LucidDataGeneric
102
107
  instance
103
108
  end
104
109
 
105
- def destroy(key:)
106
- Isomorfeus.store.deferred_dispatch(type: 'DATA_DESTROY', class_name: self.name, key: key)
107
- true
108
- end
109
-
110
110
  def escape_string(s)
111
111
  s.gsub(/([\\\&\:\(\)\[\]\{\}\!\"\~\^\|\<\>\=\*\?\+\-\s])/, '\\\\\1')
112
112
  end
@@ -117,14 +117,6 @@ class LucidObject < LucidDataGeneric
117
117
  data_class.load(key: sid.key)
118
118
  end
119
119
 
120
- def query(name, query_string, options = nil)
121
- queries[name] = { query_string: query_string, options: options }
122
- end
123
-
124
- def queries
125
- @queries ||= {}
126
- end
127
-
128
120
  def field_types
129
121
  # determines how the item is stored in the index
130
122
  @field_types ||= {}
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: 23.8.0.rc3
4
+ version: 23.9.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-26 00:00:00.000000000 Z
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.5
19
+ version: 7.0.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.5
26
+ version: 7.0.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 3.13.23
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 3.16.0
36
+ version: 3.17.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 3.13.23
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 3.16.0
46
+ version: 3.17.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: opal
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -92,84 +92,84 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.17.4
95
+ version: 0.17.5
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.17.4
102
+ version: 0.17.5
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: isomorfeus-i18n
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 23.8.0.rc3
109
+ version: 23.9.0.rc2
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 23.8.0.rc3
116
+ version: 23.9.0.rc2
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: isomorfeus-policy
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - '='
122
122
  - !ruby/object:Gem::Version
123
- version: 23.8.0.rc3
123
+ version: 23.9.0.rc2
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - '='
129
129
  - !ruby/object:Gem::Version
130
- version: 23.8.0.rc3
130
+ version: 23.9.0.rc2
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: isomorfeus-preact
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - '='
136
136
  - !ruby/object:Gem::Version
137
- version: 23.8.0.rc3
137
+ version: 23.9.0.rc2
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - '='
143
143
  - !ruby/object:Gem::Version
144
- version: 23.8.0.rc3
144
+ version: 23.9.0.rc2
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: isomorfeus-redux
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - '='
150
150
  - !ruby/object:Gem::Version
151
- version: 23.8.0.rc3
151
+ version: 23.9.0.rc2
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - '='
157
157
  - !ruby/object:Gem::Version
158
- version: 23.8.0.rc3
158
+ version: 23.9.0.rc2
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: isomorfeus-transport
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - '='
164
164
  - !ruby/object:Gem::Version
165
- version: 23.8.0.rc3
165
+ version: 23.9.0.rc2
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - '='
171
171
  - !ruby/object:Gem::Version
172
- version: 23.8.0.rc3
172
+ version: 23.9.0.rc2
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: rake
175
175
  requirement: !ruby/object:Gem::Requirement