eco-helpers 3.0.21 → 3.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/.gitignore +10 -0
  3. data/CHANGELOG.md +34 -2
  4. data/eco-helpers.gemspec +3 -3
  5. data/lib/eco/api/common/class_hierarchy.rb +6 -9
  6. data/lib/eco/api/common/loaders/case_base.rb +12 -4
  7. data/lib/eco/api/common/loaders/config/workflow/cases_extension.rb +53 -0
  8. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +2 -14
  9. data/lib/eco/api/common/loaders/config/workflow.rb +4 -0
  10. data/lib/eco/api/common/loaders/error_handler.rb +3 -2
  11. data/lib/eco/api/common/loaders/policy.rb +3 -2
  12. data/lib/eco/api/common/loaders/use_case/cli_identify.rb +28 -0
  13. data/lib/eco/api/common/loaders/use_case/target_model.rb +25 -0
  14. data/lib/eco/api/common/loaders/use_case/type.rb +37 -0
  15. data/lib/eco/api/common/loaders/use_case.rb +16 -43
  16. data/lib/eco/api/error/handler.rb +6 -4
  17. data/lib/eco/api/error/handlers.rb +12 -5
  18. data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +34 -0
  19. data/lib/eco/api/microcases/people/apply_changes/set_account.rb +28 -0
  20. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +28 -0
  21. data/lib/eco/api/microcases/people/apply_changes/set_core.rb +27 -0
  22. data/lib/eco/api/microcases/people/apply_changes/set_core_with_supervisor.rb +38 -0
  23. data/lib/eco/api/microcases/people/apply_changes/set_supervisor.rb +69 -0
  24. data/lib/eco/api/microcases/people/apply_changes.rb +19 -0
  25. data/lib/eco/api/microcases/people/fetch/with_each.rb +109 -0
  26. data/lib/eco/api/microcases/people/fetch/with_each_leaver.rb +33 -0
  27. data/lib/eco/api/microcases/people/fetch/with_each_present.rb +42 -0
  28. data/lib/eco/api/microcases/people/fetch/with_each_starter.rb +43 -0
  29. data/lib/eco/api/microcases/people/fetch/with_each_subordinate.rb +41 -0
  30. data/lib/eco/api/microcases/people/fetch/with_supervisor.rb +46 -0
  31. data/lib/eco/api/microcases/people/fetch.rb +23 -0
  32. data/lib/eco/api/microcases/people/integrity/fix_default_group.rb +39 -0
  33. data/lib/eco/api/microcases/people/integrity/fix_filter_tags.rb +55 -0
  34. data/lib/eco/api/microcases/people/integrity/refresh_default_tag.rb +32 -0
  35. data/lib/eco/api/microcases/people/integrity.rb +17 -0
  36. data/lib/eco/api/microcases/people/macro/take_email.rb +141 -0
  37. data/lib/eco/api/microcases/people/macro.rb +13 -0
  38. data/lib/eco/api/microcases/people/manage/cache.rb +36 -0
  39. data/lib/eco/api/microcases/people/manage/load.rb +90 -0
  40. data/lib/eco/api/microcases/people/manage/refresh.rb +59 -0
  41. data/lib/eco/api/microcases/people/manage/search.rb +118 -0
  42. data/lib/eco/api/microcases/people/manage.rb +19 -0
  43. data/lib/eco/api/microcases/people/preserve/default_tag.rb +29 -0
  44. data/lib/eco/api/microcases/people/preserve/filter_tags.rb +34 -0
  45. data/lib/eco/api/microcases/people/preserve/policy_groups.rb +36 -0
  46. data/lib/eco/api/microcases/people/preserve.rb +17 -0
  47. data/lib/eco/api/microcases/people.rb +21 -0
  48. data/lib/eco/api/microcases/person_update.rb +1 -1
  49. data/lib/eco/api/microcases/s3upload_targets.rb +1 -1
  50. data/lib/eco/api/microcases/with_each_contractor_present.rb +40 -0
  51. data/lib/eco/api/microcases.rb +3 -23
  52. data/lib/eco/api/organization/people/multiple_search_results.rb +48 -0
  53. data/lib/eco/api/organization/{people_similarity.rb → people/similarity.rb} +89 -72
  54. data/lib/eco/api/organization/people.rb +40 -66
  55. data/lib/eco/api/organization.rb +0 -1
  56. data/lib/eco/api/policies/policy.rb +7 -5
  57. data/lib/eco/api/policies.rb +9 -4
  58. data/lib/eco/api/session/batch/feedback/generate.rb +60 -0
  59. data/lib/eco/api/session/batch/feedback/getters.rb +28 -0
  60. data/lib/eco/api/session/batch/feedback/identifiers.rb +20 -0
  61. data/lib/eco/api/session/batch/feedback/job_dependencies.rb +45 -0
  62. data/lib/eco/api/session/batch/feedback/request_stat.rb +27 -0
  63. data/lib/eco/api/session/batch/feedback/request_stats.rb +270 -0
  64. data/lib/eco/api/session/batch/feedback.rb +45 -119
  65. data/lib/eco/api/session/batch/job/sets.rb +23 -0
  66. data/lib/eco/api/session/batch/job/type.rb +22 -0
  67. data/lib/eco/api/session/batch/job.rb +8 -18
  68. data/lib/eco/api/session/batch/jobs.rb +6 -2
  69. data/lib/eco/api/session/batch/launcher/mode_size.rb +1 -1
  70. data/lib/eco/api/session/batch/launcher/retry.rb +4 -4
  71. data/lib/eco/api/session/batch/launcher.rb +2 -2
  72. data/lib/eco/api/session/batch/policies.rb +4 -4
  73. data/lib/eco/api/session/batch/searcher.rb +2 -1
  74. data/lib/eco/api/session/batch.rb +0 -1
  75. data/lib/eco/api/session/config/workflow.rb +19 -9
  76. data/lib/eco/api/usecases/base_case/model.rb +54 -0
  77. data/lib/eco/api/usecases/base_case/type.rb +52 -0
  78. data/lib/eco/api/usecases/base_case.rb +5 -29
  79. data/lib/eco/api/usecases/base_io/chaining.rb +48 -0
  80. data/lib/eco/api/usecases/base_io/validations.rb +114 -0
  81. data/lib/eco/api/usecases/base_io.rb +65 -115
  82. data/lib/eco/api/usecases/cli/dsl.rb +3 -1
  83. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +7 -4
  84. data/lib/eco/api/usecases/default/people/treat/supers_cyclic_identify_case.rb +1 -3
  85. data/lib/eco/api/usecases/default/people/treat/supers_hierarchy_case.rb +1 -5
  86. data/lib/eco/api/usecases/default_cases/entries_to_csv_case.rb +2 -2
  87. data/lib/eco/api/usecases/default_cases/hris_case.rb +0 -2
  88. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +3 -6
  89. data/lib/eco/api/usecases/graphql/base.rb +3 -2
  90. data/lib/eco/api/usecases/graphql/helpers/base/case_env.rb +1 -1
  91. data/lib/eco/api/usecases/graphql/helpers/base/error_handling.rb +3 -3
  92. data/lib/eco/api/usecases/graphql/helpers/contractors/base/load.rb +17 -0
  93. data/lib/eco/api/usecases/graphql/helpers/contractors/base.rb +8 -0
  94. data/lib/eco/api/usecases/graphql/helpers/contractors.rb +6 -0
  95. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +5 -4
  96. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +2 -2
  97. data/lib/eco/api/usecases/graphql/helpers.rb +1 -0
  98. data/lib/eco/api/usecases/graphql/samples/contractors/dsl.rb +5 -0
  99. data/lib/eco/api/usecases/graphql/samples/contractors.rb +17 -0
  100. data/lib/eco/api/usecases/graphql/samples/location/service/base.rb +1 -1
  101. data/lib/eco/api/usecases/graphql/samples/location.rb +1 -1
  102. data/lib/eco/api/usecases/graphql/samples.rb +1 -0
  103. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +0 -1
  104. data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +8 -8
  105. data/lib/eco/api/usecases/use_case/chainer.rb +12 -0
  106. data/lib/eco/api/usecases/use_case.rb +32 -23
  107. data/lib/eco/api/usecases/use_case_chain/chaining.rb +88 -0
  108. data/lib/eco/api/usecases/use_case_chain.rb +17 -62
  109. data/lib/eco/api/usecases/use_case_io/chain.rb +24 -0
  110. data/lib/eco/api/usecases/use_case_io.rb +17 -22
  111. data/lib/eco/api/usecases.rb +12 -4
  112. data/lib/eco/assets.rb +1 -1
  113. data/lib/eco/cli/config/filters/people_filters.rb +6 -5
  114. data/lib/eco/cli/config/input.rb +6 -2
  115. data/lib/eco/cli/config/use_cases.rb +4 -2
  116. data/lib/eco/cli_default/people_filters.rb +1 -0
  117. data/lib/eco/cli_default/workflow.rb +149 -138
  118. data/lib/eco/data/mapper.rb +51 -19
  119. data/lib/eco/language/methods/dsl_able.rb +3 -0
  120. data/lib/eco/version.rb +1 -1
  121. metadata +66 -33
  122. data/lib/eco/api/microcases/account_excluded.rb +0 -26
  123. data/lib/eco/api/microcases/core_excluded.rb +0 -20
  124. data/lib/eco/api/microcases/fix_default_group.rb +0 -33
  125. data/lib/eco/api/microcases/fix_filter_tags.rb +0 -49
  126. data/lib/eco/api/microcases/people_cache.rb +0 -30
  127. data/lib/eco/api/microcases/people_load.rb +0 -84
  128. data/lib/eco/api/microcases/people_refresh.rb +0 -53
  129. data/lib/eco/api/microcases/people_search.rb +0 -112
  130. data/lib/eco/api/microcases/preserve_default_tag.rb +0 -23
  131. data/lib/eco/api/microcases/preserve_filter_tags.rb +0 -28
  132. data/lib/eco/api/microcases/preserve_policy_groups.rb +0 -30
  133. data/lib/eco/api/microcases/refresh_default_tag.rb +0 -26
  134. data/lib/eco/api/microcases/set_account.rb +0 -18
  135. data/lib/eco/api/microcases/set_core.rb +0 -17
  136. data/lib/eco/api/microcases/set_core_with_supervisor.rb +0 -32
  137. data/lib/eco/api/microcases/set_supervisor.rb +0 -63
  138. data/lib/eco/api/microcases/take_email_from_account.rb +0 -129
  139. data/lib/eco/api/microcases/with_each.rb +0 -103
  140. data/lib/eco/api/microcases/with_each_leaver.rb +0 -27
  141. data/lib/eco/api/microcases/with_each_present.rb +0 -36
  142. data/lib/eco/api/microcases/with_each_starter.rb +0 -37
  143. data/lib/eco/api/microcases/with_each_subordinate.rb +0 -33
  144. data/lib/eco/api/microcases/with_supervisor.rb +0 -35
  145. data/lib/eco/api/session/batch/request_stats.rb +0 -266
@@ -7,7 +7,9 @@ module Eco
7
7
  # original evaluate caller.
8
8
  def evaluate(*args, **kargs, &block)
9
9
  return unless block_given?
10
+
10
11
  @self_before_evaluate = eval('self', block.binding, __FILE__, __LINE__)
12
+
11
13
  instance_exec(*args, **kargs, &block).tap do
12
14
  @self_before_evaluate = nil
13
15
  end
@@ -17,6 +19,7 @@ module Eco
17
19
  # @see https://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation
18
20
  def method_missing(method, *args, **kargs, &block)
19
21
  super unless @self_before_evaluate
22
+
20
23
  @self_before_evaluate.send(method, *args, **kargs, &block)
21
24
  end
22
25
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.0.21'.freeze
2
+ VERSION = '3.0.22'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.21
4
+ version: 3.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2025-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -229,7 +229,7 @@ dependencies:
229
229
  version: '0.10'
230
230
  - - ">="
231
231
  - !ruby/object:Gem::Version
232
- version: 0.10.7
232
+ version: 0.10.8
233
233
  type: :runtime
234
234
  prerelease: false
235
235
  version_requirements: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ dependencies:
239
239
  version: '0.10'
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
- version: 0.10.7
242
+ version: 0.10.8
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: ecoportal-api-graphql
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -249,7 +249,7 @@ dependencies:
249
249
  version: '0.4'
250
250
  - - ">="
251
251
  - !ruby/object:Gem::Version
252
- version: 0.4.3
252
+ version: 0.4.4
253
253
  type: :runtime
254
254
  prerelease: false
255
255
  version_requirements: !ruby/object:Gem::Requirement
@@ -259,7 +259,7 @@ dependencies:
259
259
  version: '0.4'
260
260
  - - ">="
261
261
  - !ruby/object:Gem::Version
262
- version: 0.4.3
262
+ version: 0.4.4
263
263
  - !ruby/object:Gem::Dependency
264
264
  name: ecoportal-api-v2
265
265
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,7 @@ dependencies:
269
269
  version: '2.0'
270
270
  - - ">="
271
271
  - !ruby/object:Gem::Version
272
- version: 2.0.12
272
+ version: 2.0.15
273
273
  type: :runtime
274
274
  prerelease: false
275
275
  version_requirements: !ruby/object:Gem::Requirement
@@ -279,7 +279,7 @@ dependencies:
279
279
  version: '2.0'
280
280
  - - ">="
281
281
  - !ruby/object:Gem::Version
282
- version: 2.0.12
282
+ version: 2.0.15
283
283
  - !ruby/object:Gem::Dependency
284
284
  name: ed25519
285
285
  requirement: !ruby/object:Gem::Requirement
@@ -516,6 +516,7 @@ extensions: []
516
516
  extra_rdoc_files: []
517
517
  files:
518
518
  - ".gitignore"
519
+ - ".idea/.gitignore"
519
520
  - ".markdownlint.json"
520
521
  - ".rspec"
521
522
  - ".rubocop.yml"
@@ -541,11 +542,15 @@ files:
541
542
  - lib/eco/api/common/loaders/config/cli.rb
542
543
  - lib/eco/api/common/loaders/config/session.rb
543
544
  - lib/eco/api/common/loaders/config/workflow.rb
545
+ - lib/eco/api/common/loaders/config/workflow/cases_extension.rb
544
546
  - lib/eco/api/common/loaders/config/workflow/mailer.rb
545
547
  - lib/eco/api/common/loaders/error_handler.rb
546
548
  - lib/eco/api/common/loaders/parser.rb
547
549
  - lib/eco/api/common/loaders/policy.rb
548
550
  - lib/eco/api/common/loaders/use_case.rb
551
+ - lib/eco/api/common/loaders/use_case/cli_identify.rb
552
+ - lib/eco/api/common/loaders/use_case/target_model.rb
553
+ - lib/eco/api/common/loaders/use_case/type.rb
549
554
  - lib/eco/api/common/people.rb
550
555
  - lib/eco/api/common/people/base_parser.rb
551
556
  - lib/eco/api/common/people/default_parsers.rb
@@ -611,38 +616,47 @@ files:
611
616
  - lib/eco/api/error/handler.rb
612
617
  - lib/eco/api/error/handlers.rb
613
618
  - lib/eco/api/microcases.rb
614
- - lib/eco/api/microcases/account_excluded.rb
615
619
  - lib/eco/api/microcases/append_usergroups.rb
616
- - lib/eco/api/microcases/core_excluded.rb
617
- - lib/eco/api/microcases/fix_default_group.rb
618
- - lib/eco/api/microcases/fix_filter_tags.rb
619
- - lib/eco/api/microcases/people_cache.rb
620
- - lib/eco/api/microcases/people_load.rb
621
- - lib/eco/api/microcases/people_refresh.rb
622
- - lib/eco/api/microcases/people_search.rb
620
+ - lib/eco/api/microcases/people.rb
621
+ - lib/eco/api/microcases/people/apply_changes.rb
622
+ - lib/eco/api/microcases/people/apply_changes/set_account.rb
623
+ - lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb
624
+ - lib/eco/api/microcases/people/apply_changes/set_core.rb
625
+ - lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb
626
+ - lib/eco/api/microcases/people/apply_changes/set_core_with_supervisor.rb
627
+ - lib/eco/api/microcases/people/apply_changes/set_supervisor.rb
628
+ - lib/eco/api/microcases/people/fetch.rb
629
+ - lib/eco/api/microcases/people/fetch/with_each.rb
630
+ - lib/eco/api/microcases/people/fetch/with_each_leaver.rb
631
+ - lib/eco/api/microcases/people/fetch/with_each_present.rb
632
+ - lib/eco/api/microcases/people/fetch/with_each_starter.rb
633
+ - lib/eco/api/microcases/people/fetch/with_each_subordinate.rb
634
+ - lib/eco/api/microcases/people/fetch/with_supervisor.rb
635
+ - lib/eco/api/microcases/people/integrity.rb
636
+ - lib/eco/api/microcases/people/integrity/fix_default_group.rb
637
+ - lib/eco/api/microcases/people/integrity/fix_filter_tags.rb
638
+ - lib/eco/api/microcases/people/integrity/refresh_default_tag.rb
639
+ - lib/eco/api/microcases/people/macro.rb
640
+ - lib/eco/api/microcases/people/macro/take_email.rb
641
+ - lib/eco/api/microcases/people/manage.rb
642
+ - lib/eco/api/microcases/people/manage/cache.rb
643
+ - lib/eco/api/microcases/people/manage/load.rb
644
+ - lib/eco/api/microcases/people/manage/refresh.rb
645
+ - lib/eco/api/microcases/people/manage/search.rb
646
+ - lib/eco/api/microcases/people/preserve.rb
647
+ - lib/eco/api/microcases/people/preserve/default_tag.rb
648
+ - lib/eco/api/microcases/people/preserve/filter_tags.rb
649
+ - lib/eco/api/microcases/people/preserve/policy_groups.rb
623
650
  - lib/eco/api/microcases/person_update.rb
624
- - lib/eco/api/microcases/preserve_default_tag.rb
625
- - lib/eco/api/microcases/preserve_filter_tags.rb
626
- - lib/eco/api/microcases/preserve_policy_groups.rb
627
- - lib/eco/api/microcases/refresh_default_tag.rb
628
651
  - lib/eco/api/microcases/s3upload_targets.rb
629
- - lib/eco/api/microcases/set_account.rb
630
- - lib/eco/api/microcases/set_core.rb
631
- - lib/eco/api/microcases/set_core_with_supervisor.rb
632
- - lib/eco/api/microcases/set_supervisor.rb
633
652
  - lib/eco/api/microcases/strict_search.rb
634
- - lib/eco/api/microcases/take_email_from_account.rb
635
- - lib/eco/api/microcases/with_each.rb
636
- - lib/eco/api/microcases/with_each_leaver.rb
637
- - lib/eco/api/microcases/with_each_present.rb
638
- - lib/eco/api/microcases/with_each_starter.rb
639
- - lib/eco/api/microcases/with_each_subordinate.rb
640
- - lib/eco/api/microcases/with_supervisor.rb
653
+ - lib/eco/api/microcases/with_each_contractor_present.rb
641
654
  - lib/eco/api/organization.rb
642
655
  - lib/eco/api/organization/login_providers.rb
643
656
  - lib/eco/api/organization/node_classifications.rb
644
657
  - lib/eco/api/organization/people.rb
645
- - lib/eco/api/organization/people_similarity.rb
658
+ - lib/eco/api/organization/people/multiple_search_results.rb
659
+ - lib/eco/api/organization/people/similarity.rb
646
660
  - lib/eco/api/organization/person_schemas.rb
647
661
  - lib/eco/api/organization/policy_groups.rb
648
662
  - lib/eco/api/organization/preferences.rb
@@ -660,7 +674,15 @@ files:
660
674
  - lib/eco/api/session/batch/base_policy.rb
661
675
  - lib/eco/api/session/batch/errors.rb
662
676
  - lib/eco/api/session/batch/feedback.rb
677
+ - lib/eco/api/session/batch/feedback/generate.rb
678
+ - lib/eco/api/session/batch/feedback/getters.rb
679
+ - lib/eco/api/session/batch/feedback/identifiers.rb
680
+ - lib/eco/api/session/batch/feedback/job_dependencies.rb
681
+ - lib/eco/api/session/batch/feedback/request_stat.rb
682
+ - lib/eco/api/session/batch/feedback/request_stats.rb
663
683
  - lib/eco/api/session/batch/job.rb
684
+ - lib/eco/api/session/batch/job/sets.rb
685
+ - lib/eco/api/session/batch/job/type.rb
664
686
  - lib/eco/api/session/batch/jobs.rb
665
687
  - lib/eco/api/session/batch/jobs_groups.rb
666
688
  - lib/eco/api/session/batch/launcher.rb
@@ -671,7 +693,6 @@ files:
671
693
  - lib/eco/api/session/batch/launcher/status_handling.rb
672
694
  - lib/eco/api/session/batch/launcher/valid_methods.rb
673
695
  - lib/eco/api/session/batch/policies.rb
674
- - lib/eco/api/session/batch/request_stats.rb
675
696
  - lib/eco/api/session/batch/searcher.rb
676
697
  - lib/eco/api/session/batch/status.rb
677
698
  - lib/eco/api/session/config.rb
@@ -693,7 +714,11 @@ files:
693
714
  - lib/eco/api/session/config/workflow.rb
694
715
  - lib/eco/api/usecases.rb
695
716
  - lib/eco/api/usecases/base_case.rb
717
+ - lib/eco/api/usecases/base_case/model.rb
718
+ - lib/eco/api/usecases/base_case/type.rb
696
719
  - lib/eco/api/usecases/base_io.rb
720
+ - lib/eco/api/usecases/base_io/chaining.rb
721
+ - lib/eco/api/usecases/base_io/validations.rb
697
722
  - lib/eco/api/usecases/cli.rb
698
723
  - lib/eco/api/usecases/cli/dsl.rb
699
724
  - lib/eco/api/usecases/cli/option.rb
@@ -772,6 +797,9 @@ files:
772
797
  - lib/eco/api/usecases/graphql/helpers/base/case_env.rb
773
798
  - lib/eco/api/usecases/graphql/helpers/base/error_handling.rb
774
799
  - lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb
800
+ - lib/eco/api/usecases/graphql/helpers/contractors.rb
801
+ - lib/eco/api/usecases/graphql/helpers/contractors/base.rb
802
+ - lib/eco/api/usecases/graphql/helpers/contractors/base/load.rb
775
803
  - lib/eco/api/usecases/graphql/helpers/location.rb
776
804
  - lib/eco/api/usecases/graphql/helpers/location/base.rb
777
805
  - lib/eco/api/usecases/graphql/helpers/location/base/classifications_parser.rb
@@ -795,6 +823,8 @@ files:
795
823
  - lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_map.rb
796
824
  - lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb
797
825
  - lib/eco/api/usecases/graphql/samples.rb
826
+ - lib/eco/api/usecases/graphql/samples/contractors.rb
827
+ - lib/eco/api/usecases/graphql/samples/contractors/dsl.rb
798
828
  - lib/eco/api/usecases/graphql/samples/location.rb
799
829
  - lib/eco/api/usecases/graphql/samples/location/command.rb
800
830
  - lib/eco/api/usecases/graphql/samples/location/command/dsl.rb
@@ -844,8 +874,11 @@ files:
844
874
  - lib/eco/api/usecases/ooze_samples/register_update_case.rb
845
875
  - lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb
846
876
  - lib/eco/api/usecases/use_case.rb
877
+ - lib/eco/api/usecases/use_case/chainer.rb
847
878
  - lib/eco/api/usecases/use_case_chain.rb
879
+ - lib/eco/api/usecases/use_case_chain/chaining.rb
848
880
  - lib/eco/api/usecases/use_case_io.rb
881
+ - lib/eco/api/usecases/use_case_io/chain.rb
849
882
  - lib/eco/assets.rb
850
883
  - lib/eco/assets/language.rb
851
884
  - lib/eco/cli.rb
@@ -1,26 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
5
- # @param options [Hash] the options.
6
- # @return [Array<String>] the account parameters that should not be included.
7
- def account_excluded(person, options)
8
- [].tap do |account_excluded|
9
- unless person.new?
10
- if options.dig(:exclude, :policy_groups)
11
- account_excluded.push("policy_group_ids")
12
- end
13
-
14
- if options.dig(:exclude, :default_tag)
15
- account_excluded.push("default_tag")
16
- end
17
-
18
- if options.dig(:exclude, :login_providers)
19
- account_excluded.push("login_provider_ids")
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,20 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # @note by default `supervisor_id` is always excluded.
5
- # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
6
- # @param options [Hash] the options.
7
- # @return [Array<String>] the core parameters that should not be included.
8
- def core_excluded(person, options)
9
- ["supervisor_id"].tap do |core_excluded|
10
- can_exclude = person.new?? ["filter_tags"] : %w[name external_id email filter_tags]
11
-
12
- exclusions = can_exclude.select do |attr|
13
- options.dig(:exclude, attr.to_sym)
14
- end
15
- core_excluded.concat(exclusions)
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,33 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # If defined, it sets the default usergroup, only when the `policy_group_ids` was not part of the input data.
5
- # @param entry [PersonEntry] the input entry with the data we should set on person.
6
- # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
7
- # @param options [Hash] the options.
8
- def fix_default_group(entry, person, options)
9
- return if options.dig(:exclude, :account)
10
- return if options.dig(:exclude, :policy_groups) && !person.new?
11
-
12
- end_pg_ids = person.account.policy_group_ids
13
-
14
- if person.account_added? && __def_usergroup_id && !entry.policy_group_ids?
15
- # on account creation, if missing policy_group_ids column in the input
16
- # use default_usergroup, if it's defined
17
- end_pg_ids = [__def_usergroup_id]
18
- end
19
-
20
- person.account.policy_group_ids = end_pg_ids
21
- end
22
-
23
- private
24
-
25
- def __def_usergroup_id
26
- @__def_usergroup_id ||=
27
- if session.config.people.default_usergroup?
28
- session.policy_groups.to_id(session.config.people.default_usergroup)
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,49 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # Helper that makes sure the **custom `tags`** are preserved.
5
- # @note
6
- # - this feature is essential to preserve custom `tags` in users that have register tags.
7
- # - for this to work out, it requires a `tagtree` to be defined.
8
- # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes already done.
9
- # @param options [Hash] the options.
10
- # @option options [Hash<Symbol, Object>] :filter_tags options around `filter_tags`.
11
- # * `:preserve_custom` (Boolean) [true] indicates if original tags that are not in the tree should be added/preserved.
12
- # * `:add_custom` (Boolean) [true] indicates if target tags that are not in the tree should be really added.
13
- def fix_filter_tags(person, options)
14
- return unless session.tagtree
15
-
16
- filter_tags_excluded =
17
- options.dig(:exclude, :core) ||
18
- options.dig(:exclude, :filter_tags)
19
-
20
- return if !person.new? && filter_tags_excluded
21
-
22
- person.filter_tags = session.tagtree.user_tags(
23
- initial: person.original_doc["filter_tags"] || [],
24
- final: person.filter_tags,
25
- preserve_custom: _fix_filter_tags_preserve_custom?(options),
26
- add_custom: _fix_filter_tags_add_custom?(options)
27
- )
28
- end
29
-
30
- private
31
-
32
- # default `true`
33
- def _fix_filter_tags_preserve_custom?(options)
34
- key_defined = options.key?(:filter_tags) && options[:filter_tags].key?(:preserve_custom)
35
- return true unless key_defined
36
-
37
- options.dig(:filter_tags, :preserve_custom)
38
- end
39
-
40
- # default `true`
41
- def _fix_filter_tags_add_custom?(options)
42
- key_defined = options.key?(:filter_tags) && options[:filter_tags].key?(:add_custom)
43
- return true unless key_defined
44
-
45
- options.dig(:filter_tags, :add_custom)
46
- end
47
- end
48
- end
49
- end
@@ -1,30 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # Helper to locally cache the people manager.
5
- # @param filename [String] the name of the file where the data should be cached.
6
- # @return [Eco::API::Organization::People] the `People` object with the data.
7
- def people_cache(filename = enviro.config.people.cache)
8
- log(:info) { "Going to get all the people via API" }
9
-
10
- start = Time.now
11
- people = session.batch.get_people
12
- secs = (Time.now - start).round(3)
13
- cnt = people.count
14
- per_sec = (cnt.to_f / secs).round(2)
15
-
16
- log(:info) {
17
- "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
18
- }
19
-
20
- file = file_manager.save_json(people, filename, :timestamp)
21
-
22
- log(:info) {
23
- "#{people.length} people loaded and saved locally to #{file}."
24
- }
25
-
26
- Eco::API::Organization::People.new(people)
27
- end
28
- end
29
- end
30
- end
@@ -1,84 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # Helper to load `People` that works in different phases:
5
- # 1. first tries to get the newest cached file that follows `filename` pattern
6
- # - if not the newest, it tries to find the specific filename
7
- # 2. if it succeeds to identify a cached file, it loads it
8
- # - if it fails, it tries to get people from the server
9
- # @note
10
- # - `filename` will be relative to the working directory (the one of the session `enviro` set by the user).
11
- # @param filename [String] the name of the file where the cached data is to be found.
12
- # @param modifier [Array<Symbol>] modifiers to specify how this function should proceed:
13
- # - `:newest` if it should try to find the newest file (pattern alike).
14
- # - `:api` if it should try to get people from the server in case there's no cache.
15
- # - `:file` if it is supposed to load people from a file.
16
- # - `:save` if it is supposed to cache/save the data locally once obtained people from the server (`:api`)
17
- # @return [Eco::API::Organization::People] the `People` object with the data.
18
- def people_load(filename = enviro.config.people.cache, modifier: %i[newest api]) # rubocop:disable Metrics/AbcSize
19
- modifier = [modifier].flatten
20
- load_file = %i[file newest].any? {|flag| modifier.include?(flag)}
21
-
22
- case
23
- when filename && load_file
24
- file = people_load_filename(filename, newest: modifier.include?(:newest))
25
-
26
- if file
27
- file_manager.load_json(file).tap do |people|
28
- next unless people.is_a?(Array)
29
-
30
- log(:info) {
31
- "#{people&.length} people loaded from file #{file}"
32
- }
33
- end
34
- else
35
- log(:error) {
36
- "could not find the file #{file_manager.dir.file(filename)}"
37
- }
38
-
39
- exit unless modifier.include?(:api)
40
-
41
- people_load(modifier: modifier - %i[newest file])
42
- end
43
- when modifier.include?(:api)
44
- log(:info) { "Going to get all the people via API (load)" }
45
-
46
- start = Time.now
47
- session.batch.get_people.tap do |people|
48
- secs = (Time.now - start).round(3)
49
- cnt = people.count
50
- per_sec = (cnt.to_f / secs).round(2)
51
-
52
- log(:info) {
53
- "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)"
54
- }
55
-
56
- if modifier.include?(:save) && people && people.length.positive?
57
- file = file_manager.save_json(people, filename, :timestamp)
58
- log(:info) { "#{people.length} people saved to file #{file}." }
59
- end
60
- end
61
- end.then do |people|
62
- Eco::API::Organization::People.new(people)
63
- end
64
- end
65
-
66
- private
67
-
68
- def people_load_filename(filename, newest: false)
69
- if newest
70
- # search input file based on pattern (in case the name has a timestamp)
71
- file_manager.dir.newest_file(file: filename).tap do |file|
72
- next unless file
73
-
74
- log(:info) {
75
- "previous file found: #{file}"
76
- }
77
- end
78
- else
79
- file_manager.dir.file(filename, should_exist: true)
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,53 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # Helper to obtain all the elements of `people` anew from the _People Manager_.
5
- # @note
6
- # 1. This helper is normally used to run consecutive usecases, where data needs refresh.
7
- # 2. It only includes new people if they are not dirty (they do not have pending updates)
8
- # - This contingency wouldn't be necessary if the server worked perfectly.
9
- # @param people [Eco::API::Organization::People] the people that needs refresh.
10
- # @param include_created [Boolean] include people created during this session? (will check `:create` batch jobs).
11
- # @return [Eco::API::Organization::People] the `People` object with the data.
12
- def people_refresh(people:, include_created: true) # rubocop:disable Metrics/AbcSize
13
- people = people.newFrom people.select do |person|
14
- !person.new? || !person.dirty?
15
- end
16
-
17
- ini = people.length
18
-
19
- if include_created
20
- session.job_groups.find_jobs(type: :create).map do |job|
21
- to_add = job.people.reject(&:dirty?)
22
- people = people.merge(to_add)
23
- end
24
- end
25
-
26
- created = people.length - ini
27
- msg = "Going to refresh #{people.length} people with server data"
28
- msg << " (including #{created} that were created)" if created.positive?
29
- log(:info) { msg }
30
-
31
- start = Time.now
32
- entries = session.batch.get_people(people, silent: true)
33
- secs = (Time.now - start).round(3)
34
- cnt = entries.count
35
- per_sec = (cnt.to_f / secs).round(2)
36
-
37
- log(:info) {
38
- "Re-loaded #{cnt} people (out of #{people.length}) in #{secs} seconds (#{per_sec} people/sec)"
39
- }
40
-
41
- missing = people.length - entries.length
42
-
43
- if missing.positive?
44
- log(:error) {
45
- "Missed to obtain #{missing} people during the refresh"
46
- }
47
- end
48
-
49
- Eco::API::Organization::People.new(entries)
50
- end
51
- end
52
- end
53
- end
@@ -1,112 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # Helper to search/obtain people from `data` against the server (_People Manager_).
5
- # @note
6
- # - this helper is normally used to **get partial** part of the people manager.
7
- # - therefore, normally used with _**delta** input files_ (files with only the differences).
8
- # @param data [Eco::API::Organization::People, Enumerable<Person>, Enumerable<Hash>]
9
- # `People` to search against the server.
10
- # @param options [Hash] the options.
11
- # @param silent [Boolean] `false` if low level search messages should be shown.
12
- # @return [Eco::API::Organization::People] the `People` object with the found persons.
13
- def people_search(data, options: {}, silent: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
14
- log(:info) { "Going to api get #{data.length} entries..." }
15
-
16
- silent &&= data.count <= 500
17
-
18
- start = Time.now
19
- people = session.batch.search(data, silent: silent).then do |status|
20
- secs = (Time.now - start).round(3)
21
-
22
- Eco::API::Organization::People.new(status.people).tap do |people| # rubocop:disable Lint/ShadowingOuterLocalVariable
23
- cnt = people.count
24
- per_sec = (cnt.to_f / secs).round(2)
25
-
26
- msg = "... could get #{cnt} people "
27
- msg << "(out of #{data.length} entries) in #{secs} seconds (#{per_sec} people/sec)"
28
-
29
- log(:info) { msg }
30
- end
31
- end
32
-
33
- # get the supervisors of found people (current supervisors)
34
- supers = people_search_prepare_supers_request(people)
35
- if supers.length.positive?
36
- log(:info) {
37
- " Going to api get #{supers.length} current supervisors..."
38
- }
39
-
40
- start = Time.now
41
- people = session.batch.search(supers, silent: silent).then do |status|
42
- secs = (Time.now - start).round(3)
43
- found = status.people
44
- cnt = found.count
45
- per_sec = (cnt.to_f / secs).round(2)
46
-
47
- msg = "... could find #{cnt} current supers "
48
- msg << "(out of #{supers.length}) in #{secs} seconds (#{per_sec} people/sec)"
49
- log(:info) { msg }
50
-
51
- people.merge(found, strict: micro.strict_search?(options))
52
- end
53
- end
54
-
55
- # get the supervisors referred in the input data (future supervisors)
56
- supers = people_search_prepare_supers_request(data, people)
57
- if supers.length.positive?
58
- log(:info) {
59
- " Going to api get #{supers.length} supervisors as per input entries..."
60
- }
61
-
62
- start = Time.now
63
- people = session.batch.search(supers, silent: silent).then do |status|
64
- secs = (Time.now - start).round(3)
65
- found = status.people
66
- cnt = found.count
67
- per_sec = (cnt.to_f / secs).round(2)
68
-
69
- msg = "... could find #{cnt} input supers "
70
- msg << "(out of #{supers.length}) in #{secs} seconds (#{per_sec} people/sec)"
71
- log(:info) { msg }
72
-
73
- people.merge(found, strict: micro.strict_search?(options))
74
- end
75
- end
76
-
77
- log(:info) {
78
- "Finally got #{people.length} people (out of #{data.length} entries)"
79
- }
80
-
81
- people
82
- end
83
-
84
- private
85
-
86
- # Prepares a unique request with only the supervisor ids missing in `people`
87
- def people_search_prepare_supers_request(data, people = data)
88
- data.each_with_object([]) do |entry, request|
89
- spr = {"id" => (sup_id = people_search_super_id(entry))}
90
- next if !sup_id || request.include?(spr)
91
-
92
- micro.with_supervisor(sup_id, people) do |supervisor|
93
- request.push(spr) unless supervisor
94
- end
95
- end
96
- end
97
-
98
- # Gets the `supervisor_id` from `value`
99
- def people_search_super_id(value)
100
- sup_id =
101
- if value.respond_to?(:supervisor_id)
102
- value.supervisor_id
103
- elsif value.is_a?(Hash) && value.key("supervisor_id")
104
- value["supervisor_id"]
105
- end
106
-
107
- sup_id = nil if sup_id.to_s.strip.empty?
108
- sup_id
109
- end
110
- end
111
- end
112
- end