eco-helpers 1.5.12 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +74 -1
  3. data/eco-helpers.gemspec +31 -29
  4. data/lib/eco/api.rb +1 -1
  5. data/lib/eco/api/common/class_helpers.rb +45 -1
  6. data/lib/eco/api/common/loaders/error_handler.rb +2 -0
  7. data/lib/eco/api/common/loaders/parser.rb +4 -0
  8. data/lib/eco/api/common/loaders/use_case.rb +2 -0
  9. data/lib/eco/api/common/people/person_entry.rb +15 -3
  10. data/lib/eco/api/common/session/logger.rb +9 -1
  11. data/lib/eco/api/common/session/logger/cache.rb +91 -0
  12. data/lib/eco/api/common/session/logger/log.rb +48 -0
  13. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +9 -0
  14. data/lib/eco/api/microcases/people_cache.rb +7 -0
  15. data/lib/eco/api/microcases/people_load.rb +29 -21
  16. data/lib/eco/api/microcases/people_refresh.rb +6 -0
  17. data/lib/eco/api/microcases/people_search.rb +33 -8
  18. data/lib/eco/api/policies.rb +1 -0
  19. data/lib/eco/api/policies/default_policies.rb +12 -0
  20. data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +88 -0
  21. data/lib/eco/api/session.rb +13 -0
  22. data/lib/eco/api/session/batch.rb +0 -3
  23. data/lib/eco/api/session/batch/job.rb +17 -7
  24. data/lib/eco/api/session/config/api.rb +1 -1
  25. data/lib/eco/api/session/config/workflow.rb +1 -0
  26. data/lib/eco/api/usecases.rb +1 -0
  27. data/lib/eco/api/usecases/ooze_samples.rb +11 -0
  28. data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +131 -0
  29. data/lib/eco/version.rb +1 -1
  30. metadata +42 -47
  31. data/lib/eco/api/usecases/backup/append_usergroups_case.rb +0 -36
  32. data/lib/eco/api/usecases/backup/create_case.rb +0 -104
  33. data/lib/eco/api/usecases/backup/create_details_case.rb +0 -31
  34. data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +0 -48
  35. data/lib/eco/api/usecases/backup/hris_case.rb +0 -124
  36. data/lib/eco/api/usecases/backup/set_default_tag_case.rb +0 -49
  37. data/lib/eco/api/usecases/backup/set_supervisor_case.rb +0 -41
  38. data/lib/eco/api/usecases/backup/transfer_account_case.rb +0 -90
  39. data/lib/eco/api/usecases/backup/update_case.rb +0 -112
  40. data/lib/eco/api/usecases/backup/update_details_case.rb +0 -64
  41. data/lib/eco/api/usecases/backup/upsert_case.rb +0 -114
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.5.12"
2
+ VERSION = "2.0.3"
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: 1.5.12
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -16,67 +16,67 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.3
19
+ version: 2.2.11
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.2'
22
+ version: '2.3'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.3
29
+ version: 2.2.11
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.2'
32
+ version: '2.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '3.9'
39
+ version: 3.10.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4'
42
+ version: '3.11'
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '3.9'
49
+ version: 3.10.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4'
52
+ version: '3.11'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rake
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 12.3.0
59
+ version: 13.0.3
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '13'
62
+ version: '13.1'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 12.3.0
69
+ version: 13.0.3
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '13'
72
+ version: '13.1'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: yard
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.9.18
79
+ version: 0.9.26
80
80
  - - "<"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.10'
@@ -86,7 +86,7 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.9.18
89
+ version: 0.9.26
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0.10'
@@ -96,7 +96,7 @@ dependencies:
96
96
  requirements:
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 3.5.0
99
+ version: 3.5.1
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '3.6'
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 3.5.0
109
+ version: 3.5.1
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.6'
@@ -116,47 +116,47 @@ dependencies:
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.7.4
119
+ version: 0.8.1
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.8'
122
+ version: '0.9'
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: 0.7.4
129
+ version: 0.8.1
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
- version: '0.8'
132
+ version: '0.9'
133
133
  - !ruby/object:Gem::Dependency
134
- name: ecoportal-api-oozes
134
+ name: ecoportal-api-v2
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 0.7.2
139
+ version: 0.8.3
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
- version: '0.8'
142
+ version: '0.9'
143
143
  type: :runtime
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: 0.7.2
149
+ version: 0.8.3
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.8'
152
+ version: '0.9'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: aws-sdk-s3
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 1.64.0
159
+ version: 1.83.0
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '2'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 1.64.0
169
+ version: 1.83.0
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '2'
@@ -176,7 +176,7 @@ dependencies:
176
176
  requirements:
177
177
  - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: 1.29.0
179
+ version: 1.36.0
180
180
  - - "<"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '2'
@@ -186,7 +186,7 @@ dependencies:
186
186
  requirements:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
- version: 1.29.0
189
+ version: 1.36.0
190
190
  - - "<"
191
191
  - !ruby/object:Gem::Version
192
192
  version: '2'
@@ -196,7 +196,7 @@ dependencies:
196
196
  requirements:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: 2.7.0
199
+ version: 2.7.6
200
200
  - - "<"
201
201
  - !ruby/object:Gem::Version
202
202
  version: '2.8'
@@ -206,7 +206,7 @@ dependencies:
206
206
  requirements:
207
207
  - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 2.7.0
209
+ version: 2.7.6
210
210
  - - "<"
211
211
  - !ruby/object:Gem::Version
212
212
  version: '2.8'
@@ -216,20 +216,20 @@ dependencies:
216
216
  requirements:
217
217
  - - ">="
218
218
  - !ruby/object:Gem::Version
219
- version: 2.1.2
219
+ version: 3.0.0
220
220
  - - "<"
221
221
  - !ruby/object:Gem::Version
222
- version: '2.2'
222
+ version: '3.1'
223
223
  type: :runtime
224
224
  prerelease: false
225
225
  version_requirements: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
228
228
  - !ruby/object:Gem::Version
229
- version: 2.1.2
229
+ version: 3.0.0
230
230
  - - "<"
231
231
  - !ruby/object:Gem::Version
232
- version: '2.2'
232
+ version: '3.1'
233
233
  description:
234
234
  email:
235
235
  - oscar@ecoportal.co.nz
@@ -286,6 +286,8 @@ files:
286
286
  - lib/eco/api/common/session/environment.rb
287
287
  - lib/eco/api/common/session/file_manager.rb
288
288
  - lib/eco/api/common/session/logger.rb
289
+ - lib/eco/api/common/session/logger/cache.rb
290
+ - lib/eco/api/common/session/logger/log.rb
289
291
  - lib/eco/api/common/session/mailer.rb
290
292
  - lib/eco/api/common/session/s3_uploader.rb
291
293
  - lib/eco/api/common/session/sftp.rb
@@ -342,6 +344,8 @@ files:
342
344
  - lib/eco/api/organization/presets_values.json
343
345
  - lib/eco/api/organization/tag_tree.rb
344
346
  - lib/eco/api/policies.rb
347
+ - lib/eco/api/policies/default_policies.rb
348
+ - lib/eco/api/policies/default_policies/99_user_access_policy.rb
345
349
  - lib/eco/api/policies/policy.rb
346
350
  - lib/eco/api/session.rb
347
351
  - lib/eco/api/session/batch.rb
@@ -367,17 +371,6 @@ files:
367
371
  - lib/eco/api/session/config/sftp.rb
368
372
  - lib/eco/api/session/config/workflow.rb
369
373
  - lib/eco/api/usecases.rb
370
- - lib/eco/api/usecases/backup/append_usergroups_case.rb
371
- - lib/eco/api/usecases/backup/create_case.rb
372
- - lib/eco/api/usecases/backup/create_details_case.rb
373
- - lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb
374
- - lib/eco/api/usecases/backup/hris_case.rb
375
- - lib/eco/api/usecases/backup/set_default_tag_case.rb
376
- - lib/eco/api/usecases/backup/set_supervisor_case.rb
377
- - lib/eco/api/usecases/backup/transfer_account_case.rb
378
- - lib/eco/api/usecases/backup/update_case.rb
379
- - lib/eco/api/usecases/backup/update_details_case.rb
380
- - lib/eco/api/usecases/backup/upsert_case.rb
381
374
  - lib/eco/api/usecases/base_case.rb
382
375
  - lib/eco/api/usecases/base_io.rb
383
376
  - lib/eco/api/usecases/default_cases.rb
@@ -412,6 +405,8 @@ files:
412
405
  - lib/eco/api/usecases/default_cases/update_case.rb
413
406
  - lib/eco/api/usecases/default_cases/update_details_case.rb
414
407
  - lib/eco/api/usecases/default_cases/upsert_case.rb
408
+ - lib/eco/api/usecases/ooze_samples.rb
409
+ - lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
415
410
  - lib/eco/api/usecases/use_case.rb
416
411
  - lib/eco/api/usecases/use_case_chain.rb
417
412
  - lib/eco/api/usecases/use_case_io.rb
@@ -1,36 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class AppendUsergroupsCase < DefaultCase
6
-
7
- def process
8
- @cases.define("append-usergroups", type: :sync) do |entries, people, session, options, usecase|
9
- update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :details, :account])
10
-
11
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
12
- pgs = session.policy_groups
13
-
14
- entries.each.with_index do |entry, i|
15
- if person = people.find(entry, strict: strict_search)
16
- if person.account
17
- ini_pg_ids = person.account&.policy_group_ids || []
18
- add = entry.internal_entry["policy_group_ids"].to_s.split("|").compact
19
- person.account.policy_group_ids = (ini_pg_ids | add).uniq
20
-
21
- person.account.permissions_custom = session.new_preset(person) unless options.dig(:exclude, :abilities)
22
- update.add(person)
23
- end
24
- else
25
- session.logger.error("This person does not exist: #{entry.to_s(:identify)}")
26
- end
27
- end
28
- end
29
-
30
- end
31
-
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,104 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class CreateCase < DefaultCase
6
-
7
- def process
8
- @cases.define("create", type: :sync) do |entries, people, session, options, usecase|
9
- creation = session.job_group("main").new("create", usecase: usecase, type: :create, sets: [:core, :details, :account])
10
- supers = session.job_group("post").new("supers", usecase: usecase, type: :update, sets: :core)
11
-
12
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
13
- pgs = session.policy_groups
14
-
15
- if session.config.people.default_usergroup?
16
- def_id = pgs.to_id(session.config.people.default_usergroup)
17
- end
18
-
19
- entries.each.with_index do |entry, i|
20
- if person = people.find(entry, strict: strict_search)
21
- session.logger.error("This person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}")
22
- else
23
- person = session.new_person
24
- core_excluded = ["supervisor_id"]
25
-
26
- ini_tags = person.filter_tags || []
27
- entry.set_core(person, exclude: core_excluded)
28
-
29
- if session.tagtree
30
- person.filter_tags = session.tagtree.user_tags(
31
- initial: ini_tags,
32
- final: person.filter_tags,
33
- preserve_custom: true,
34
- add_custom: true
35
- )
36
- end
37
-
38
- entry.set_details(person) unless options.dig(:exclude, :details)
39
-
40
- unless options.dig(:exclude, :account)
41
- add_account = !person.account
42
- ini_pg_ids = person.account&.policy_group_ids || []
43
-
44
- account_excluded = []
45
- account_excluded.push("policy_group_ids") if options.dig(:exclude, :policy_groups) && !create
46
-
47
- entry.set_account(person, exclude: account_excluded)
48
-
49
- person.account&.send_invites = options[:send_invites] if options.key?(:send_invites)
50
-
51
- unless options.dig(:exclude, :policy_groups) && !create
52
- end_pg_ids = person.account.policy_group_ids || []
53
-
54
- if add_account && def_id && !entry.policy_group_ids?
55
- # on account creation, if missing policy_group_ids column in the input
56
- # use default_usergroup, if it's defined
57
- end_pg_ids = [def_id]
58
- end
59
-
60
- # avoid false updates by preserving the original order
61
- person.account.policy_group_ids = pgs.user_pg_ids(
62
- initial: ini_pg_ids,
63
- final: end_pg_ids
64
- )
65
- end
66
-
67
- person.account.permissions_custom = session.new_preset(person)
68
-
69
- if session.tagtree
70
- person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
71
- else
72
- tags = person.filter_tags || []
73
- person.account.default_tag = tags.first unless tags.length > 1
74
- end
75
- end
76
-
77
- creation.add(person)
78
-
79
- # set supervisor
80
- unless options.dig(:exclude, :core) || options.dig(:exclude, :supervisor)
81
- if !(sup_id = entry.supervisor_id)
82
- person.supervisor_id = nil
83
- else
84
- if supervisor = people.person(id: sup_id, external_id: sup_id, email: sup_id)
85
- person.supervisor_id = supervisor.id
86
- else
87
- # delay setting supervisor if does not exit
88
- supers.add(person) do |person|
89
- person.supervisor_id = sup_id
90
- end
91
- end
92
- end
93
- end
94
-
95
- end
96
- end
97
- end
98
- end
99
-
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -1,31 +0,0 @@
1
- module Eco
2
- module API
3
- class UseCases
4
- class DefaultCases
5
- class CreateDetailsCase < DefaultCase
6
-
7
- def process
8
- @cases.define("create-details", type: :sync) do |entries, people, session, options, usecase|
9
- creation = session.job_group("main").new("create", usecase: usecase, type: :create, sets: [:core, :details])
10
-
11
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
12
-
13
- entries.each.with_index do |entry, i|
14
- if person = people.find(entry, strict: strict_search)
15
- session.logger.error("This person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}")
16
- else
17
- person = session.new_person
18
- entry.set_core(person, exclude: "supervisor_id")
19
- entry.set_details(person)
20
-
21
- creation.add(person)
22
- end
23
- end
24
- end
25
- end
26
-
27
- end
28
- end
29
- end
30
- end
31
- end