eco-helpers 2.0.11 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -71
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/person_entry.rb +5 -0
- data/lib/eco/api/common/people/supervisor_helpers.rb +27 -0
- data/lib/eco/api/common/session/file_manager.rb +2 -2
- data/lib/eco/api/error.rb +5 -3
- data/lib/eco/api/organization/presets_factory.rb +166 -82
- data/lib/eco/api/organization/presets_integrity.json +52 -0
- data/lib/eco/api/session/batch.rb +19 -3
- data/lib/eco/api/session/batch/job.rb +3 -0
- data/lib/eco/api/session/config.rb +16 -5
- data/lib/eco/api/session/config/api.rb +4 -0
- data/lib/eco/api/session/config/apis.rb +14 -0
- data/lib/eco/api/session/config/files.rb +7 -0
- data/lib/eco/api/session/config/people.rb +2 -2
- data/lib/eco/api/usecases.rb +2 -0
- data/lib/eco/api/usecases/default_cases.rb +3 -0
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +161 -0
- data/lib/eco/api/usecases/default_cases/hris_case.rb +14 -8
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +72 -0
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +59 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +41 -21
- data/lib/eco/cli.rb +1 -10
- data/lib/eco/cli/config/default/usecases.rb +20 -2
- data/lib/eco/cli/config/default/workflow.rb +5 -0
- data/lib/eco/data/files/directory.rb +28 -20
- data/lib/eco/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669f1a3e8d49a2499b02d925386477a8e52cc633c830072420484edcf8e4919d
|
4
|
+
data.tar.gz: 86b36286a089bfa03d3cb17d4c17648a4dcc5f1ed07145ee81565cd19d102c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a346a01757374cc004c12b5aadadf6b3c1daebba937c8d1c0cf597608297ab825d604af3a7f70f92528e28e0f009fd482abd31eb660c4abcf9d9796f55f69db
|
7
|
+
data.tar.gz: f912a967dfb21cb0e455b357c9f5ca28fae4de55cbacd060fd000add64992b86168a3ed38150d1ddaf9a264245da582a49c434d62d24bc28285d82b3f9a2e693
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,54 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.0.
|
4
|
+
## [2.0.16] - 2021-04-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
+
- Use case `Eco::API::UseCases::DefaultCases::SupersCyclicIdentify`, invokable via `-identify-cyclic-supers`
|
8
|
+
- Use case `Eco::API::UseCases::DefaultCases::AbstractPolicyGroupAbilities`, invokable via `-abstract-policygroup-abilities`
|
9
|
+
- Option to run `one-off` scripts, without org configurations:
|
10
|
+
1. `-api-key INTERNAL_API_KEY`
|
11
|
+
2. `-enviro [live|pre.dev]`
|
12
|
+
3. `-org NAME_OF_ORG`
|
7
13
|
|
8
14
|
### Changed
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
|
18
|
+
## [2.0.15] - 2021-04-29
|
19
|
+
|
20
|
+
### Added
|
21
|
+
- Use case `Eco::API::UseCases::DefaultCases::SupersHierarchy`, invokable via `-supers-hiearchy`
|
22
|
+
### Fixed
|
23
|
+
- `eco/cli/config/default/workflow.rb` prevent `rescue` looping
|
24
|
+
|
25
|
+
## [2.0.14] - 2021-04-15
|
26
|
+
|
27
|
+
### Added
|
28
|
+
- `Eco::API::UseCases::DefaultCases::ToCsvCase` added option `-internal-names` to avoid overriding data on export
|
29
|
+
- `Eco::API::Common::People::PersonEntry#mapped_entry` exposed method for raw `csv` generation
|
30
|
+
- `Eco::API::Organization::PresetsFactory` added integrity validation for `person_*` abilities
|
31
|
+
- `Eco::API::Session::Batch::Job` more debug info on erron handlers
|
32
|
+
|
33
|
+
### Fixed
|
34
|
+
- `Eco::API::Error.get_type` was almost always matching `Eco::API::Error::Unclassified` -> fixed
|
35
|
+
|
36
|
+
## [2.0.13] - 2021-03-31
|
37
|
+
|
38
|
+
### Added
|
39
|
+
- Stats on the `Eco::API::Session::Batch`
|
40
|
+
- Allow to inherit and re-use the `Eco::API::UseCases::DefaultCase::HrisCase`
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
- Ensure auto-loading for `Eco::API::UseCases`
|
44
|
+
|
45
|
+
## [2.0.12] - 2021-03-29
|
46
|
+
|
47
|
+
### Changed
|
48
|
+
- `Eco::CLI#run` it does include any defined states on the workflow
|
49
|
+
|
50
|
+
|
51
|
+
## [2.0.11] - 2021-03-29
|
9
52
|
|
10
53
|
### Fixed
|
11
54
|
- `Eco::API::Session::Batch:Errors#errors` changed `Array#filter` call to `Array#select` call
|
@@ -25,34 +68,24 @@ All notable changes to this project will be documented in this file.
|
|
25
68
|
- Ranamed `#defined_attrs` to `#defined_model_attrs`
|
26
69
|
- Ranamed `#undefined_attrs` to `#undefined_model_attrs`
|
27
70
|
|
28
|
-
### Fixed
|
29
|
-
|
30
71
|
## [2.0.9] - 2021-03-19
|
31
72
|
|
32
|
-
### Added
|
33
73
|
### Changed
|
34
74
|
- `Eco::API::Session::Batch:Errors#person_ref` moved to the public method
|
35
75
|
|
36
|
-
### Fixed
|
37
|
-
|
38
76
|
## [2.0.8] - 2021-03-09
|
39
77
|
|
40
|
-
### Added
|
41
|
-
### Changed
|
42
78
|
### Fixed
|
43
79
|
- `Ecoportal::API::V1::Person#identity` adjust behavior
|
44
80
|
|
45
81
|
## [2.0.7] - 2021-03-09
|
46
82
|
|
47
|
-
### Added
|
48
|
-
### Changed
|
49
83
|
### Fixed
|
50
84
|
- `Eco::API::Session::Batch::JobsGroups` and `Eco::API::Session::Batch::Jobs`: when new `Batch::Job`s are creating during launch, they remained unlaunched
|
51
85
|
- this fix makes `#launch` method to iterate until there are no pending
|
52
86
|
|
53
87
|
## [2.0.6] - 2021-03-08
|
54
88
|
|
55
|
-
### Added
|
56
89
|
### Changed
|
57
90
|
- `Eco::API::Session::Batch:Errors` moved some methods to be private
|
58
91
|
### Fixed
|
@@ -60,46 +93,33 @@ All notable changes to this project will be documented in this file.
|
|
60
93
|
|
61
94
|
## [2.0.5] - 2021-02-24
|
62
95
|
|
63
|
-
### Added
|
64
|
-
### Changed
|
65
96
|
### Fixed
|
66
97
|
- `Eco::API::Common::People::PersonParser#symbol_keys` to use `Array#select`
|
67
98
|
- as `Array#filter` was introduced in ruby `2.5.5`
|
68
99
|
|
69
100
|
## [2.0.4] - 2021-02-23
|
70
101
|
|
71
|
-
### Added
|
72
102
|
### Changed
|
73
103
|
- `Eco::API::Common::People::PersonParser#defined_attrs` to include virtual attributes
|
74
104
|
|
75
|
-
### Fixed
|
76
|
-
|
77
105
|
## [2.0.3] - 2021-02-23
|
78
106
|
|
79
107
|
### Added
|
80
108
|
- `Eco::API::UseCases::OozeSamples::OozeUpdateCase`: added integration to update page instances (non-templates)
|
81
109
|
|
82
|
-
### Changed
|
83
110
|
### Fixed
|
84
111
|
- `Eco::API::Policies::DefaultPolicies::UserAccess` complete default policy code.
|
85
112
|
|
86
113
|
## [2.0.2] - 2021-02-22
|
87
114
|
|
88
|
-
### Added
|
89
115
|
### Changed
|
90
116
|
- upgraded dependencies with `ecoportal-api`
|
91
117
|
|
92
|
-
### Fixed
|
93
|
-
|
94
|
-
|
95
118
|
## [2.0.1] - 2021-02-22
|
96
119
|
|
97
|
-
### Added
|
98
120
|
### Changed
|
99
121
|
- upgraded dependencies with `ecoportal-api-oozes` to `ecoportal-api-v2`
|
100
122
|
|
101
|
-
### Fixed
|
102
|
-
|
103
123
|
## [1.5.15] - 2021-02-17
|
104
124
|
|
105
125
|
### Added
|
@@ -113,7 +133,6 @@ All notable changes to this project will be documented in this file.
|
|
113
133
|
- `Eco::API::MicroCases#people_search`
|
114
134
|
- `Eco::API::MicroCases#refresh`
|
115
135
|
|
116
|
-
### Changed
|
117
136
|
### Fixed
|
118
137
|
- `Eco::API::Policies::DefaultPolicies::UserAccess` typos in default api policy
|
119
138
|
|
@@ -135,11 +154,8 @@ All notable changes to this project will be documented in this file.
|
|
135
154
|
- `Eco::API::Common::People::PersonEntry` add error log when wrong email error is detected
|
136
155
|
- previously it would have crashed
|
137
156
|
|
138
|
-
### Fixed
|
139
|
-
|
140
157
|
## [1.5.13] - 2021-02-01
|
141
158
|
|
142
|
-
### Added
|
143
159
|
### Changed
|
144
160
|
- upgraded dependency with `ecoportal-api-oozes`
|
145
161
|
|
@@ -155,23 +171,16 @@ All notable changes to this project will be documented in this file.
|
|
155
171
|
### Changed
|
156
172
|
- upgraded `ecoportal-api` dependency
|
157
173
|
|
158
|
-
### Fixed
|
159
|
-
|
160
|
-
|
161
174
|
## [1.5.11] - 2021-01-25
|
162
175
|
|
163
176
|
### Added
|
164
177
|
- `Eco::API::Organization::TagTree#subtag?` to check if the tag is in any subtree.
|
165
178
|
|
166
|
-
### Changed
|
167
|
-
|
168
179
|
### Fixed
|
169
180
|
- `Eco::API::MicroCases#set_supervisor` shouldn't set it if the entry does not have it.
|
170
181
|
|
171
182
|
## [1.5.10] - 2021-01-19
|
172
183
|
|
173
|
-
### Added
|
174
|
-
### Changed
|
175
184
|
### Fixed
|
176
185
|
- `Eco::API::Session::Batch::Errors#print` show the row number of the input data.
|
177
186
|
|
@@ -180,14 +189,8 @@ All notable changes to this project will be documented in this file.
|
|
180
189
|
### Added
|
181
190
|
- `Eco::API::Organization::TagTree#subtags` to get all the tags but those of the highest level.
|
182
191
|
|
183
|
-
### Changed
|
184
|
-
### Fixed
|
185
|
-
|
186
|
-
|
187
192
|
## [1.5.8] - 2021-01-05
|
188
193
|
|
189
|
-
### Added
|
190
|
-
### Changed
|
191
194
|
### Fixed
|
192
195
|
- `Eco::API::Session::Batch::Jobs#job` shouldn't be calling the post-launch callback function on creation.
|
193
196
|
- `Eco::API::Session#new_job` should include a `&block` parameter.
|
@@ -195,15 +198,11 @@ All notable changes to this project will be documented in this file.
|
|
195
198
|
|
196
199
|
## [1.5.7] - 2020-12-17
|
197
200
|
|
198
|
-
### Added
|
199
|
-
### Changed
|
200
201
|
### Fixed
|
201
202
|
- `Eco::API::Sesssion#parse_attribute` was not using phase argument
|
202
203
|
|
203
204
|
## [1.5.6] - 2020-12-04
|
204
205
|
|
205
|
-
### Added
|
206
|
-
### Changed
|
207
206
|
### Fixed
|
208
207
|
- `Eco::API::UseCases::DefaultCases::RestoreDBCase` fixed typo and slightly improved
|
209
208
|
- fixed some back-end errors when chaining usecases
|
@@ -211,8 +210,6 @@ All notable changes to this project will be documented in this file.
|
|
211
210
|
|
212
211
|
## [1.5.5] - 2020-12-03
|
213
212
|
|
214
|
-
### Added
|
215
|
-
### Changed
|
216
213
|
### Fixed
|
217
214
|
- rubies previous to `2.5` do not have `yield_self`
|
218
215
|
|
@@ -220,14 +217,11 @@ All notable changes to this project will be documented in this file.
|
|
220
217
|
|
221
218
|
### Added
|
222
219
|
- update `ecoportal-api` dependency
|
223
|
-
### Changed
|
224
220
|
### Fixed
|
225
221
|
- `Eco::API::MicroCases#people_refresh` typo
|
226
222
|
|
227
223
|
## [1.5.3] - 2020-11-30
|
228
224
|
|
229
|
-
### Added
|
230
|
-
### Changed
|
231
225
|
### Fixed
|
232
226
|
- `Eco::API::Session::Batch::RequestStats#blanked_value?` better blank detection
|
233
227
|
- `Eco::API::MicroCases#with_each_starter` rectified typo
|
@@ -368,14 +362,11 @@ All notable changes to this project will be documented in this file.
|
|
368
362
|
|
369
363
|
## [1.4.2] - 2020-07-23
|
370
364
|
|
371
|
-
### Added
|
372
|
-
### Changed
|
373
365
|
### Fixed
|
374
366
|
- preserve backtrace on logging
|
375
367
|
|
376
368
|
## [1.4.0] - 2020-07-14
|
377
369
|
|
378
|
-
### Added
|
379
370
|
### Changed
|
380
371
|
- change abilities to align with ecoPortal release `1.5.0`
|
381
372
|
- remove some patches on `ecoportal-api`
|
@@ -385,22 +376,17 @@ All notable changes to this project will be documented in this file.
|
|
385
376
|
|
386
377
|
## [1.3.19] - 2020-07-23
|
387
378
|
|
388
|
-
### Added
|
389
|
-
### Changed
|
390
379
|
### Fixed
|
391
380
|
- preserve backtrace on logging
|
392
381
|
|
393
382
|
## [1.3.18] - 2020-07-08
|
394
383
|
|
395
|
-
### Added
|
396
|
-
### Changed
|
397
384
|
### Fixed
|
398
385
|
- the `update` case was missing the code to use the `default_usergroup`
|
399
386
|
|
400
387
|
|
401
388
|
## [1.3.17] - 2020-07-06
|
402
389
|
|
403
|
-
### Added
|
404
390
|
### Changed
|
405
391
|
- the `hris` case should not only include as `leavers` those that have account, but anyone that leaves
|
406
392
|
* as we could have active people with no account
|
@@ -423,7 +409,6 @@ All notable changes to this project will be documented in this file.
|
|
423
409
|
### Added
|
424
410
|
- default usecase to export to `csv` (`-detailed`) now includes `"Supervisor Name"` column
|
425
411
|
### Changed
|
426
|
-
### Fixed
|
427
412
|
|
428
413
|
## [1.3.14] - 2020-06-10
|
429
414
|
|
@@ -431,33 +416,24 @@ All notable changes to this project will be documented in this file.
|
|
431
416
|
- `Eco::API::Common::People::SupervisorHelpers` now has its methods as class methods
|
432
417
|
### Changed
|
433
418
|
- upgraded `ecoportal-api` gem dependency to minimum version `0.5.6`
|
434
|
-
### Fixed
|
435
419
|
|
436
420
|
|
437
421
|
## [1.3.13] - 2020-05-29
|
438
422
|
|
439
|
-
### Added
|
440
|
-
### Changed
|
441
423
|
### Fixed
|
442
424
|
- `Eco::API::Organization::TagTree#tag?` to accept `nil` by returning `false`
|
443
425
|
- `Eco::API::Common::People::DefaultParsers::DateParser` will parse to `Date` class
|
444
426
|
* it was parsing to `Time` class, while the native gem `ecoportal-api` parses as `Date` ([reference](https://gitlab.com/ecoPortal/ecoportal-api/-/blob/master/lib/ecoportal/api/v1/schema_field.rb))
|
445
427
|
## [1.3.12] - 2020-05-19
|
446
428
|
|
447
|
-
### Added
|
448
429
|
### Changed
|
449
430
|
- stop using `email` as `external_id` on `People#person` & `People#find`
|
450
431
|
* this should result in more accurate searches when using `:strict` options
|
451
|
-
### Fixed
|
452
|
-
|
453
432
|
|
454
433
|
## [1.3.11] - 2020-05-12
|
455
434
|
|
456
|
-
### Added
|
457
435
|
### Changed
|
458
436
|
- remove popping up comments on `Eco::API::Organization::PolicyGroups#`
|
459
|
-
### Fixed
|
460
|
-
|
461
437
|
|
462
438
|
## [1.3.10] - 2020-05-12
|
463
439
|
|
@@ -466,14 +442,11 @@ All notable changes to this project will be documented in this file.
|
|
466
442
|
- `config.people.default_usergroup`, when defined, will have effect on usecases: `update` (this case was missing the change)
|
467
443
|
* on account creation, if the input file did not specify `policy_group_ids`
|
468
444
|
|
469
|
-
### Changed
|
470
445
|
### Fixed
|
471
446
|
- `upsert`, `hris` and `create` usecases: fixed condition for use of default_usergroup
|
472
447
|
|
473
448
|
## [1.3.9] - 2020-05-12
|
474
449
|
|
475
|
-
### Added
|
476
|
-
### Changed
|
477
450
|
### Fixed
|
478
451
|
|
479
452
|
- `usecase` callback was not receiving `usecase` paramater
|
data/eco-helpers.gemspec
CHANGED
@@ -8,7 +8,7 @@ module Eco
|
|
8
8
|
# @return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
|
9
9
|
def type(value = nil)
|
10
10
|
unless value
|
11
|
-
return @type || raise("You should specify a type of case [:sync, :transform, :import, :other] for #{self
|
11
|
+
return @type || raise("You should specify a type of case [:sync, :transform, :import, :other] for #{self}")
|
12
12
|
end
|
13
13
|
@type = value
|
14
14
|
end
|
@@ -57,6 +57,11 @@ module Eco
|
|
57
57
|
@internal_entry
|
58
58
|
end
|
59
59
|
|
60
|
+
# @return [Hash] entry `Hash` with **internal** attribute names, but **external** types and values.
|
61
|
+
def mapped_entry
|
62
|
+
@mapped_entry
|
63
|
+
end
|
64
|
+
|
60
65
|
# @note values ready to be set to a person.
|
61
66
|
# @return [Hash] entry `Hash` with **internal** attribute names, values and types.
|
62
67
|
def final_entry
|
@@ -15,6 +15,7 @@ module Eco
|
|
15
15
|
# Reorders as follows:
|
16
16
|
# 1. supervisors, people with no supervisor or where their supervisor not present
|
17
17
|
# 2. subordinates
|
18
|
+
# @return [Array<Entry>] `values` sorted by supervisors/subordinates
|
18
19
|
def sort_by_supervisors(values, supervisors_first: true)
|
19
20
|
raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
|
20
21
|
return [] unless values && values.is_a?(Enumerable)
|
@@ -32,6 +33,32 @@ module Eco
|
|
32
33
|
roam.call(supervisors_tree(values))
|
33
34
|
end
|
34
35
|
|
36
|
+
# Identifies all the cyclic supervisor chains
|
37
|
+
# @note as `supervisors_tree` will have any entry involved in a cycle at the top, it just checks all the top entries against their offspring
|
38
|
+
# @return [Array<Array>] the sets of entries that are cyclic
|
39
|
+
def identify_cyclic_chains(values)
|
40
|
+
raise "Expected non hash Enumerable. Given: #{values.class}" if values.is_a?(Hash)
|
41
|
+
return [] unless values && values.is_a?(Enumerable)
|
42
|
+
|
43
|
+
identify = Proc.new do |top_sup, offspring, chain = [top_sup]|
|
44
|
+
next [] if offspring.empty?
|
45
|
+
offspring.each_with_object([]) do |(sup, subordinates), set|
|
46
|
+
break set unless set.empty?
|
47
|
+
if top_sup.supervisor_id == sup.id
|
48
|
+
set.concat(chain, [sup])
|
49
|
+
else
|
50
|
+
set = identify.call(top_sup, subordinates, chain | [sup])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
supervisors_tree(values).each_with_object([]) do |(top_sup, offspring), sets|
|
56
|
+
if (set = identify.call(top_sup, offspring)) && !set.empty?
|
57
|
+
sets.push(set)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
35
62
|
def tree_to_str(tree, lev: 0)
|
36
63
|
raise "Required Hash tree structure. Given: #{tree.class}" unless tree.is_a?(Hash)
|
37
64
|
"".tap do |str|
|
@@ -20,8 +20,8 @@ module Eco
|
|
20
20
|
begin
|
21
21
|
@dir = Eco::Data::Files::Directory.new(value)
|
22
22
|
@dir_path = @dir.create
|
23
|
-
rescue
|
24
|
-
logger.error("could not create or make any sense of directory '#{value}'")
|
23
|
+
rescue Exception => e
|
24
|
+
logger.error("could not create or make any sense of directory '#{value}': #{e.to_s}")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/eco/api/error.rb
CHANGED
@@ -80,6 +80,7 @@ module Eco
|
|
80
80
|
next 1 if k1 < k2
|
81
81
|
0
|
82
82
|
end.tap do |siblings|
|
83
|
+
siblings.delete(Unclassified)
|
83
84
|
if direct
|
84
85
|
siblings.reject! do |si|
|
85
86
|
siblings.any? {|s| si < s}
|
@@ -96,17 +97,18 @@ module Eco
|
|
96
97
|
err_msg =~ @match
|
97
98
|
end
|
98
99
|
|
99
|
-
def get_type(err_msg)
|
100
|
+
def get_type(err_msg, first: true)
|
100
101
|
type = nil
|
101
102
|
descendants(direct: true).reverse.each do |klass|
|
102
103
|
if klass.err_match?(err_msg)
|
103
104
|
type = klass
|
104
105
|
if klass.descendants?(direct: true)
|
105
|
-
type = klass.get_type(err_msg) || type
|
106
|
+
type = klass.get_type(err_msg, first: false) || type
|
106
107
|
end
|
107
108
|
end
|
108
109
|
end
|
109
|
-
type
|
110
|
+
return type unless first
|
111
|
+
type || Unclassified
|
110
112
|
end
|
111
113
|
|
112
114
|
def known_err_class?(klass)
|