eco-helpers 2.7.8 → 2.7.10

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: 73af9e54de9fc73f1986db49810ae91ad2a8c0153c26d40681873cc52754a923
4
- data.tar.gz: eb978a976711797b852cfbf2d39f68cfc760906463753a8440e9c6f595269c51
3
+ metadata.gz: 1e9c00a0ecc4c1fb42d808e2df03a8618c7017be7a27e6319859bd7974b3638a
4
+ data.tar.gz: f9e2452935fcfc3712e53b5e5731151f1ddf6a4f946f2e1c6f8c629f48e09e9e
5
5
  SHA512:
6
- metadata.gz: c454c5ec9ed3713e6bb4fd0e73b582343d5bc96fe6de677b63070838af87b93cb86dad96d1446ba4c6ead007587798c90d30d7c73cea601067db6acd9da32156
7
- data.tar.gz: afd3bb1f221ddd4db2056a5347799f88c0ad70bbf6dbf868c1f8a231a1ee311df252db2e899f95ada3e31925b8376d74145bb55b0449aa88793d10b33dea1583
6
+ metadata.gz: 4e4595657f37f057269bbd38671858700bdcc22e2755e3b365bbe69e48e017e11974a8583b5e93c09c1abf90cd4f09c0ed8ac4a853be8d471c51719fa1500e71
7
+ data.tar.gz: 0e3af7794e45e62fdbb2ba06340cc7b23ea88466670eb8b597c4e279556bb5cc59dfa5f8ff0f294f77d15dfd159819590cd2228d05fa19af8a2421d4b665fa72
data/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.7.9] - 2024-05-xx
4
+ ## [2.7.12] - 2024-05-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.7.11] - 2024-05-20
11
+
12
+ ### Changed
13
+ - Upgrade SFTP access
14
+
15
+ ## [2.7.10] - 2024-05-16
16
+
17
+ ### Changed
18
+ - Temporarily silent warnings on tracking id changes (apparently the tracking locations tree is not up to date with latest version and gives false warnings)
19
+
20
+ ### Fixed
21
+ - Remove enviro from tagtree download
22
+
23
+ ## [2.7.9] - 2024-05-16
24
+
25
+ ### Fixed
26
+ - `Eco::Data::Locations::NodeDiff::NodesDiff#unarchive`
27
+ - It must include archived nodes that will receive new children
28
+
10
29
  ## [2.7.8] - 2024-05-16
11
30
 
12
31
  ### Added
data/eco-helpers.gemspec CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'ecoportal-api', '>= 0.9.8', '< 0.10'
34
34
  spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
35
35
  spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.18', '< 0.4'
36
+ spec.add_dependency 'ed25519', '>= 1.2'
37
+ spec.add_dependency 'bcrypt_pbkdf', '>= 1.0'
36
38
  spec.add_dependency 'aws-sdk-s3', '>= 1.142.0', '< 2'
37
39
  spec.add_dependency 'aws-sdk-ses', '>= 1.58.0', '< 2'
38
40
  spec.add_dependency 'dotenv', '>= 2.8.1', '< 3'
@@ -40,11 +40,13 @@ module Eco
40
40
  # @param tagtree [String] representation of the tagtree in json.
41
41
  def initialize(
42
42
  tagtree = [],
43
- name: nil, id: nil,
44
- depth: -1, path: [],
45
- parent: nil, _weight: nil # rubocop:disable Lint/UnderscorePrefixedVariableName
43
+ name: nil,
44
+ id: nil,
45
+ depth: -1,
46
+ path: [],
47
+ parent: nil,
48
+ _weight: nil # rubocop:disable Lint/UnderscorePrefixedVariableName
46
49
  )
47
-
48
50
  @source = parse_source_input(tagtree)
49
51
 
50
52
  msg = "You are trying to initialize a TagTree with a null tagtree"
@@ -21,12 +21,16 @@ module Eco
21
21
  # 1. If there's a file tagtree.json file, it uses it
22
22
  # 2. If no file, retrieves `structure_id` (config)
23
23
  # @param include_archived [Boolean] whether or not it should include archived nodes.
24
+ # @param [recache] used for re-caching
24
25
  # @return [Eco::API::Organization::TagTree]
25
- def scope_tree(enviro: nil, include_archived: true, raise_on_missing: true) # rubocop:disable Lint/UnusedMethodArgument
26
- return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
26
+ def scope_tree(
27
+ include_archived: true,
28
+ recache: false,
29
+ raise_on_missing: true # rubocop:disable Lint/UnusedMethodArgument
30
+ )
31
+ return @tagtree if instance_variable_defined?(:@tagtree) && !recache
27
32
 
28
33
  kargs = {
29
- enviro: enviro,
30
34
  includeArchivedNodes: include_archived
31
35
  }
32
36
 
@@ -48,16 +52,16 @@ module Eco
48
52
 
49
53
  # Among all the locations structures it selects the one with more location nodes
50
54
  # If `id` is provided, it only retrieves this locations structure.
51
- # @param [enviro] used for re-caching
52
- def live_tree(id: nil, enviro: nil, include_archived: false, **kargs, &block) # rubocop:disable Metrics/AbcSize
55
+ # @param [recache] used for re-caching
56
+ def live_tree( # rubocop:disable Metrics/AbcSize
57
+ id: nil,
58
+ include_archived: false,
59
+ **kargs,
60
+ &block
61
+ )
53
62
  existing_cache = !@live_tree.nil?
54
63
  first_load = !existing_cache
55
-
56
- target_change = existing_cache && id && @live_tree.id != id
57
- enviro_change = existing_cache && enviro && @live_tree.enviro != enviro
58
-
59
- switching_target = existing_cache && (target_change || enviro_change)
60
- _refresh_cache = existing_cache && !switching_target
64
+ switching_target = existing_cache && id && @live_tree.id != id
61
65
 
62
66
  kargs = {
63
67
  includeArchivedNodes: include_archived
@@ -248,10 +248,17 @@ module Eco
248
248
  # @note it does NOT include archived nodes by default.
249
249
  # - This is for legacy (most usecases don't)
250
250
  # @param include_archived [Boolean] whether or not it should include archived nodes.
251
+ # @param [recache] used for re-caching
251
252
  # @return [Eco::API::Organization::TagTree]
252
- def tagtree(enviro: nil, include_archived: false, raise_on_missing: true)
253
+ def tagtree(
254
+ include_archived: false,
255
+ recache: false,
256
+ raise_on_missing: true
257
+ )
253
258
  kargs = {
254
- enviro: enviro, include_archived: include_archived, raise_on_missing: raise_on_missing
259
+ recache: recache,
260
+ include_archived: include_archived,
261
+ raise_on_missing: raise_on_missing
255
262
  }
256
263
  @tagtree ||= tagtree_config.scope_tree(**kargs)
257
264
  end
@@ -259,8 +266,8 @@ module Eco
259
266
  # It obtains the first of the live tagtree in the org
260
267
  # @note it requires graphql connection configuration parameters
261
268
  # @return [Eco::API::Organization::TagTree]
262
- def live_tree(id: nil, enviro: nil, **kargs, &block)
263
- tagtree_config.live_tree(id: id, enviro: enviro, **kargs, &block)
269
+ def live_tree(id: nil, **kargs, &block)
270
+ tagtree_config.live_tree(id: id, **kargs, &block)
264
271
  end
265
272
 
266
273
  # Retrieves all the location structures of the organisation
@@ -58,19 +58,26 @@ module Eco
58
58
  # @see Eco::API::Session::Config#tagtree
59
59
  # @see Eco::API::Session#live_trees
60
60
  # @return [Eco::API::Organization::TagTree]
61
- def tagtree(live: false, merge: false, include_archived: false, **kargs, &block)
61
+ def tagtree(
62
+ live: false,
63
+ merge: false,
64
+ include_archived: false,
65
+ recache: false,
66
+ **kargs,
67
+ &block
68
+ )
62
69
  if live && api?(version: :graphql)
63
70
  return live_tree(include_archived: include_archived, **kargs, &block) unless merge
64
71
  live_trees(include_archived: include_archived, **kargs, &block).inject(&:merge)
65
72
  else
66
- config.tagtree(enviro: enviro)
73
+ config.tagtree(recache: recache)
67
74
  end
68
75
  end
69
76
 
70
77
  # @see Eco::API::Session::Config#live_tree
71
78
  # @return [Eco::API::Organization::TagTree]
72
79
  def live_tree(id: nil, include_archived: false, **kargs, &block)
73
- config.live_tree(id: id, include_archived: include_archived, enviro: enviro, **kargs, &block)
80
+ config.live_tree(id: id, include_archived: include_archived, **kargs, &block)
74
81
  end
75
82
 
76
83
  # @see Eco::API::Session::Config#live_tree
@@ -35,8 +35,10 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff
35
35
  h['parentId'] = after_id_update ? parent_id : parent_id_prev
36
36
  end
37
37
  else
38
+ return h if marked_for_unarchive?
39
+
38
40
  # Something is wrong (not expected to be any other category)
39
- raise "Unexpected condition, please review code base"
41
+ raise "Please review code base, unexpected condition for #{h.pretty_inspect}"
40
42
  end
41
43
  end
42
44
  end
@@ -57,12 +57,12 @@ class Eco::API::UseCases::GraphQL::Samples::Location
57
57
 
58
58
  tags_remap_table << [[prev_id], [new_id]]
59
59
 
60
- next unless ref_tree.is_a?(Eco::API::Organization::TagTree)
61
- next unless ref_tree.tag?(new_id)
60
+ # next unless ref_tree.is_a?(Eco::API::Organization::TagTree)
61
+ # next unless ref_tree.tag?(new_id)
62
62
 
63
- msg = "Node '#{prev_id}' was updated to '#{new_id}', "
64
- msg << "but in current structure '#{new_id}' is not present"
65
- log(:warn) { msg }
63
+ # msg = "Node '#{prev_id}' was updated to '#{new_id}', "
64
+ # msg << "but in current structure '#{new_id}' is not present"
65
+ # log(:warn) { msg }
66
66
  end
67
67
  end
68
68
 
@@ -20,8 +20,8 @@ class Eco::Data::Locations::NodeDiff
20
20
  def attr_expose(*attrs)
21
21
  attrs.each do |attr|
22
22
  meth = attr.to_sym
23
- methp = "#{meth}_prev".to_sym
24
- methq = "#{meth}?".to_sym
23
+ methp = :"#{meth}_prev"
24
+ methq = :"#{meth}?"
25
25
 
26
26
  # current value
27
27
  define_method meth do
@@ -5,8 +5,9 @@ class Eco::Data::Locations::NodeDiff::NodesDiff
5
5
  # @note the selector method name with a question mark should exist in the `diff_result_class`
6
6
  def selector(*attrs)
7
7
  attrs.each do |attr|
8
- meth = attr.to_sym
9
- methq = "#{meth}?".to_sym
8
+ meth = attr.to_sym
9
+ methq = :"#{meth}?"
10
+
10
11
  define_method meth do
11
12
  diffs.select(&methq)
12
13
  end
@@ -21,6 +21,7 @@ class Eco::Data::Locations::NodeDiff
21
21
  def initialize(*args, original_tree:, **kargs, &block)
22
22
  super(*args, **kargs, &block)
23
23
  @original_tree = original_tree
24
+ mark_implicit_unarchive!
24
25
  end
25
26
 
26
27
  def diffs
@@ -95,6 +96,14 @@ class Eco::Data::Locations::NodeDiff
95
96
  msg.compact.join("\n")
96
97
  end
97
98
 
99
+ alias_method :unarchive_src, :unarchive
100
+
101
+ # @note we must unarchive destination parents that will get
102
+ # some children as well
103
+ def unarchive
104
+ unarchive_src | @implicit_unarchive
105
+ end
106
+
98
107
  private
99
108
 
100
109
  def when_present(list, default = nil)
@@ -103,5 +112,26 @@ class Eco::Data::Locations::NodeDiff
103
112
  return yield(count) if count&.positive?
104
113
  default
105
114
  end
115
+
116
+ def mark_implicit_unarchive!
117
+ @implicit_unarchive = source_results.select do |result|
118
+ result.archived_prev && implicit_unarchive?(result)
119
+ end.tap do |results|
120
+ results.each(&:unarchive!)
121
+ end
122
+ end
123
+
124
+ def implicit_unarchive?(result)
125
+ [result.node_id, result.node_id_prev].compact.any? do |id|
126
+ target_parent_ids.include?(id)
127
+ end
128
+ end
129
+
130
+ def target_parent_ids
131
+ return @target_parent_ids if instance_variable_defined?(:@target_parent_ids)
132
+
133
+ @target_parent_ids = insert.map(&:parent_id).uniq
134
+ @target_parent_ids |= move.map(&:parent_id)
135
+ end
106
136
  end
107
137
  end
@@ -59,8 +59,17 @@ module Eco::Data::Locations
59
59
  parent_id?
60
60
  end
61
61
 
62
+ def unarchive!
63
+ @marked_for_unarchived = true
64
+ end
65
+
66
+ def marked_for_unarchive?
67
+ @marked_for_unarchived || false
68
+ end
69
+
62
70
  # Has the `archived` property changed and it was `true`?
63
71
  def unarchive?
72
+ return true if marked_for_unarchive?
64
73
  return false if archived
65
74
  return false unless update?
66
75
  archived?
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.8'.freeze
2
+ VERSION = '2.7.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.8
4
+ version: 2.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -170,6 +170,34 @@ dependencies:
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'
173
+ - !ruby/object:Gem::Dependency
174
+ name: ed25519
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '1.2'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '1.2'
187
+ - !ruby/object:Gem::Dependency
188
+ name: bcrypt_pbkdf
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '1.0'
194
+ type: :runtime
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '1.0'
173
201
  - !ruby/object:Gem::Dependency
174
202
  name: aws-sdk-s3
175
203
  requirement: !ruby/object:Gem::Requirement