eco-helpers 2.7.24 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +16 -1
  5. data/eco-helpers.gemspec +12 -11
  6. data/lib/eco/api/common/session/base_session.rb +1 -0
  7. data/lib/eco/api/common/session/helpers/prompt_user.rb +3 -1
  8. data/lib/eco/api/common/session/helpers.rb +0 -9
  9. data/lib/eco/api/common/session/logger.rb +2 -0
  10. data/lib/eco/api/microcases/account_excluded.rb +2 -0
  11. data/lib/eco/api/microcases/append_usergroups.rb +4 -6
  12. data/lib/eco/api/microcases/core_excluded.rb +2 -1
  13. data/lib/eco/api/microcases/fix_default_group.rb +13 -14
  14. data/lib/eco/api/microcases/people_cache.rb +10 -3
  15. data/lib/eco/api/microcases/people_load.rb +21 -7
  16. data/lib/eco/api/microcases/people_refresh.rb +11 -3
  17. data/lib/eco/api/microcases/people_search.rb +24 -10
  18. data/lib/eco/api/microcases/person_update.rb +8 -4
  19. data/lib/eco/api/microcases/preserve_default_tag.rb +9 -9
  20. data/lib/eco/api/microcases/preserve_policy_groups.rb +14 -14
  21. data/lib/eco/api/microcases/refresh_default_tag.rb +11 -12
  22. data/lib/eco/api/microcases/s3upload_targets.rb +3 -2
  23. data/lib/eco/api/microcases/set_account.rb +6 -7
  24. data/lib/eco/api/microcases/strict_search.rb +0 -1
  25. data/lib/eco/api/microcases/take_email_from_account.rb +46 -27
  26. data/lib/eco/api/microcases/with_each.rb +15 -5
  27. data/lib/eco/api/microcases/with_each_leaver.rb +1 -1
  28. data/lib/eco/api/microcases/with_each_present.rb +6 -2
  29. data/lib/eco/api/microcases/with_each_starter.rb +7 -3
  30. data/lib/eco/api/microcases/with_each_subordinate.rb +0 -1
  31. data/lib/eco/api/microcases/with_supervisor.rb +0 -1
  32. data/lib/eco/api/microcases.rb +0 -2
  33. data/lib/eco/api/organization/login_providers.rb +23 -5
  34. data/lib/eco/api/session.rb +1 -1
  35. data/lib/eco/cli_default/input.rb +17 -14
  36. data/lib/eco/cli_default/options.rb +41 -23
  37. data/lib/eco/cli_default/people.rb +50 -12
  38. data/lib/eco/cli_default/people_filters.rb +1 -1
  39. data/lib/eco/cli_default/workflow.rb +4 -0
  40. data/lib/eco/data/files/helpers.rb +1 -0
  41. data/lib/eco/version.rb +1 -1
  42. data/lib/eco-helpers.rb +4 -0
  43. metadata +18 -60
  44. /data/{.markdownlint.jsonc → .markdownlint.json} +0 -0
@@ -1,31 +1,69 @@
1
+ MAX_GET_PARTIAL = 12_000
2
+
1
3
  ASSETS.cli.config do |cnf|
2
4
  cnf.people do |input, session, options|
3
- get = options.dig(:people, :get) || {}
4
- case
5
- when get == false
5
+ get = options.dig(:people, :get)
6
+ get = {} if get.nil?
7
+
8
+ from_remote = get && get[:from] == :remote
9
+ from_local = get && get[:from] == :local
10
+
11
+ get_full = from_remote && get[:type] == :full
12
+ get_partial = from_remote && get[:type] == :partial
13
+ get_by_file = from_local && get[:type] == :file
14
+
15
+ # -get-partial: validate input present and under max
16
+ if get_partial
17
+ msg = "To use -get-partial (partial updates), you need to use -entries-from"
18
+ raise msg unless input.is_a?(Enumerable)
19
+
20
+ if input.count > MAX_GET_PARTIAL
21
+ get_full = true
22
+ get_partial = false
23
+
24
+ msg = "(Optimization) "
25
+ msg << "Switching from partial to full people download. "
26
+ msg << "Input (#{input.count}) surpases MAX_GET_PARTIAL (#{MAX_GET_PARTIAL}) entries."
27
+ session.logger.info(msg)
28
+
29
+ options.deep_merge!(people: {
30
+ get: {
31
+ from: :remote,
32
+ type: :full
33
+ }
34
+ })
35
+ end
36
+ end
37
+
38
+ if get == false
6
39
  Eco::API::Organization::People.new([])
7
- when (get[:from] == :remote) && get[:type] == :full
40
+ elsif get_full
8
41
  # -get-people
9
42
  session.micro.people_cache
10
- when (get[:from] == :remote) && get[:type] == :partial
43
+ elsif get_partial
11
44
  # -get-partial
12
- unless (input && input.is_a?(Enumerable))
13
- raise "To use -get-partial (partial updates), you need to use -entries-from"
14
- end
15
45
  session.micro.people_search(input, options: options)
16
- when (get[:from] == :local) && get[:type] == :file
46
+ elsif get_by_file
17
47
  # -people-from-backup
18
48
  session.micro.people_load(get[:file], modifier: :file)
19
49
  #people = JSON.parse(File.read(get[:file]))
20
50
  #Eco::API::Organization::People.new(people)
21
51
  else
22
52
  options.deep_merge!(people: {
23
- get: {from: :local, type: :full}
53
+ get: {
54
+ from: :local,
55
+ type: :full
56
+ }
24
57
  })
25
- people = session.micro.people_load(modifier: [:newest, :save])
58
+
59
+ people = session.micro.people_load(modifier: %i[newest save])
60
+
26
61
  if people.empty?
27
62
  options.deep_merge!(people: {
28
- get: {from: :remote, type: :full}
63
+ get: {
64
+ from: :remote,
65
+ type: :full
66
+ }
29
67
  })
30
68
  people = session.micro.people_cache
31
69
  end
@@ -94,7 +94,7 @@ ASSETS.cli.config do |cnf|
94
94
  end
95
95
 
96
96
  options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
97
- session.logger.info("Filtering people entries with schema #{session.schemas.to_name(sch_id)}")
97
+ session.logger.info("Filtering people records with schema #{session.schemas.to_name(sch_id)}")
98
98
 
99
99
  people.select do |person|
100
100
  person.details && (person.details.schema_id == sch_id)
@@ -4,6 +4,7 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
4
4
  # default rescue
5
5
  wf.rescue do |err, io|
6
6
  next io if rescued
7
+
7
8
  rescued = true
8
9
  log(:debug) { err.patch_full_message }
9
10
  wf.run(:close, io: io)
@@ -47,11 +48,13 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
47
48
  io.class.people_required?(usecase.type)
48
49
  end
49
50
  next if cases_with_people.empty? && !options.dig(:people, :get)
51
+
50
52
  io.new(people: cli.config.people(io: io))
51
53
  end
52
54
 
53
55
  wf_peo.on(:filter) do |_wf_pf, io|
54
56
  next unless people && !people.empty?
57
+
55
58
  io.new(people: cli.config.people_filters.process(io: io))
56
59
  end
57
60
  end
@@ -61,6 +64,7 @@ ASSETS.cli do |cli| # rubocop:disable Metrics/BlockLength
61
64
  # save partial entries -> should be native to session.workflow
62
65
  get_people = options.dig(:people, :get)
63
66
  partial_update = get_people && get_people[:type] == :partial
67
+
64
68
  if !options[:dry_run] && partial_update
65
69
  partial_file = session.config.people.partial_cache
66
70
  session.file_manager.save_json(io.people, partial_file, :timestamp)
@@ -28,6 +28,7 @@ module Eco
28
28
 
29
29
  content.scrub do |bytes|
30
30
  replacement = "<#{bytes.unpack1('H*')}>"
31
+
31
32
  if tolerance <= 0
32
33
  logger.error("There were more than 5 encoding errors in the file '#{file}'.")
33
34
  return content
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.24'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
data/lib/eco-helpers.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Naming/FileName
1
2
  require 'csv'
2
3
  require 'json'
3
4
  require 'pp'
@@ -7,6 +8,7 @@ require 'dotenv/load'
7
8
  module Eco
8
9
  end
9
10
 
11
+ require_relative 'eco/version'
10
12
  require_relative 'eco/language'
11
13
  require_relative 'eco/common'
12
14
  require_relative 'eco/data'
@@ -14,3 +16,5 @@ require_relative 'eco/csv'
14
16
  require_relative 'eco/api'
15
17
  require_relative 'eco/cli'
16
18
  require_relative 'eco/assets'
19
+
20
+ # rubocop:enable Naming/FileName
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.24
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-05 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 2.4.12
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '3'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 2.4.12
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '3'
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: rake
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -236,82 +216,58 @@ dependencies:
236
216
  name: dotenv
237
217
  requirement: !ruby/object:Gem::Requirement
238
218
  requirements:
239
- - - ">="
240
- - !ruby/object:Gem::Version
241
- version: 2.8.1
242
- - - "<"
219
+ - - "~>"
243
220
  - !ruby/object:Gem::Version
244
221
  version: '3'
245
222
  type: :runtime
246
223
  prerelease: false
247
224
  version_requirements: !ruby/object:Gem::Requirement
248
225
  requirements:
249
- - - ">="
250
- - !ruby/object:Gem::Version
251
- version: 2.8.1
252
- - - "<"
226
+ - - "~>"
253
227
  - !ruby/object:Gem::Version
254
228
  version: '3'
255
229
  - !ruby/object:Gem::Dependency
256
230
  name: ecoportal-api
257
231
  requirement: !ruby/object:Gem::Requirement
258
232
  requirements:
259
- - - ">="
260
- - !ruby/object:Gem::Version
261
- version: 0.9.8
262
- - - "<"
233
+ - - "~>"
263
234
  - !ruby/object:Gem::Version
264
235
  version: '0.10'
265
236
  type: :runtime
266
237
  prerelease: false
267
238
  version_requirements: !ruby/object:Gem::Requirement
268
239
  requirements:
269
- - - ">="
270
- - !ruby/object:Gem::Version
271
- version: 0.9.8
272
- - - "<"
240
+ - - "~>"
273
241
  - !ruby/object:Gem::Version
274
242
  version: '0.10'
275
243
  - !ruby/object:Gem::Dependency
276
244
  name: ecoportal-api-graphql
277
245
  requirement: !ruby/object:Gem::Requirement
278
246
  requirements:
279
- - - ">="
280
- - !ruby/object:Gem::Version
281
- version: 0.3.18
282
- - - "<"
247
+ - - "~>"
283
248
  - !ruby/object:Gem::Version
284
249
  version: '0.4'
285
250
  type: :runtime
286
251
  prerelease: false
287
252
  version_requirements: !ruby/object:Gem::Requirement
288
253
  requirements:
289
- - - ">="
290
- - !ruby/object:Gem::Version
291
- version: 0.3.18
292
- - - "<"
254
+ - - "~>"
293
255
  - !ruby/object:Gem::Version
294
256
  version: '0.4'
295
257
  - !ruby/object:Gem::Dependency
296
258
  name: ecoportal-api-v2
297
259
  requirement: !ruby/object:Gem::Requirement
298
260
  requirements:
299
- - - ">="
300
- - !ruby/object:Gem::Version
301
- version: 1.1.8
302
- - - "<"
261
+ - - "~>"
303
262
  - !ruby/object:Gem::Version
304
- version: '1.2'
263
+ version: '2.0'
305
264
  type: :runtime
306
265
  prerelease: false
307
266
  version_requirements: !ruby/object:Gem::Requirement
308
267
  requirements:
309
- - - ">="
310
- - !ruby/object:Gem::Version
311
- version: 1.1.8
312
- - - "<"
268
+ - - "~>"
313
269
  - !ruby/object:Gem::Version
314
- version: '1.2'
270
+ version: '2.0'
315
271
  - !ruby/object:Gem::Dependency
316
272
  name: ed25519
317
273
  requirement: !ruby/object:Gem::Requirement
@@ -534,9 +490,10 @@ extensions: []
534
490
  extra_rdoc_files: []
535
491
  files:
536
492
  - ".gitignore"
537
- - ".markdownlint.jsonc"
493
+ - ".markdownlint.json"
538
494
  - ".rspec"
539
495
  - ".rubocop.yml"
496
+ - ".ruby-version"
540
497
  - ".yardopts"
541
498
  - CHANGELOG.md
542
499
  - Gemfile
@@ -923,7 +880,8 @@ files:
923
880
  homepage: https://www.ecoportal.com
924
881
  licenses:
925
882
  - MIT
926
- metadata: {}
883
+ metadata:
884
+ rubygems_mfa_required: 'true'
927
885
  post_install_message:
928
886
  rdoc_options: []
929
887
  require_paths:
@@ -932,14 +890,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
932
890
  requirements:
933
891
  - - ">="
934
892
  - !ruby/object:Gem::Version
935
- version: 2.7.2
893
+ version: 3.2.2
936
894
  required_rubygems_version: !ruby/object:Gem::Requirement
937
895
  requirements:
938
896
  - - ">="
939
897
  - !ruby/object:Gem::Version
940
898
  version: '0'
941
899
  requirements: []
942
- rubygems_version: 3.4.12
900
+ rubygems_version: 3.5.6
943
901
  signing_key:
944
902
  specification_version: 4
945
903
  summary: eco-helpers to manage people api cases
File without changes