eco-helpers 2.0.16 → 2.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +125 -6
  3. data/eco-helpers.gemspec +10 -5
  4. data/lib/eco-helpers.rb +2 -0
  5. data/lib/eco/api/common/base_loader.rb +18 -0
  6. data/lib/eco/api/common/loaders/parser.rb +1 -0
  7. data/lib/eco/api/common/people/default_parsers.rb +1 -0
  8. data/lib/eco/api/common/people/default_parsers/date_parser.rb +11 -1
  9. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
  10. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +11 -11
  11. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +53 -0
  12. data/lib/eco/api/common/people/entries.rb +1 -0
  13. data/lib/eco/api/common/people/entry_factory.rb +88 -23
  14. data/lib/eco/api/common/people/person_entry.rb +5 -2
  15. data/lib/eco/api/common/people/person_parser.rb +1 -1
  16. data/lib/eco/api/common/session.rb +1 -0
  17. data/lib/eco/api/common/session/base_session.rb +2 -0
  18. data/lib/eco/api/common/session/helpers.rb +30 -0
  19. data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
  20. data/lib/eco/api/common/session/mailer.rb +0 -1
  21. data/lib/eco/api/common/session/s3_uploader.rb +0 -1
  22. data/lib/eco/api/common/session/sftp.rb +0 -1
  23. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
  24. data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
  25. data/lib/eco/api/common/version_patches/exception.rb +11 -4
  26. data/lib/eco/api/microcases.rb +3 -1
  27. data/lib/eco/api/microcases/append_usergroups.rb +0 -1
  28. data/lib/eco/api/microcases/people_cache.rb +2 -2
  29. data/lib/eco/api/microcases/people_load.rb +2 -2
  30. data/lib/eco/api/microcases/people_refresh.rb +2 -2
  31. data/lib/eco/api/microcases/people_search.rb +6 -6
  32. data/lib/eco/api/microcases/preserve_default_tag.rb +23 -0
  33. data/lib/eco/api/microcases/preserve_filter_tags.rb +28 -0
  34. data/lib/eco/api/microcases/preserve_policy_groups.rb +30 -0
  35. data/lib/eco/api/microcases/set_account.rb +0 -1
  36. data/lib/eco/api/microcases/with_each.rb +67 -6
  37. data/lib/eco/api/microcases/with_each_present.rb +4 -2
  38. data/lib/eco/api/microcases/with_each_starter.rb +4 -2
  39. data/lib/eco/api/organization.rb +1 -0
  40. data/lib/eco/api/organization/people.rb +98 -22
  41. data/lib/eco/api/organization/people_similarity.rb +272 -0
  42. data/lib/eco/api/organization/person_schemas.rb +5 -1
  43. data/lib/eco/api/organization/policy_groups.rb +5 -1
  44. data/lib/eco/api/organization/presets_factory.rb +22 -83
  45. data/lib/eco/api/organization/presets_integrity.json +6 -0
  46. data/lib/eco/api/organization/presets_values.json +5 -4
  47. data/lib/eco/api/organization/tag_tree.rb +33 -0
  48. data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +0 -30
  49. data/lib/eco/api/session.rb +20 -28
  50. data/lib/eco/api/session/batch.rb +25 -7
  51. data/lib/eco/api/session/config.rb +0 -10
  52. data/lib/eco/api/session/config/apis.rb +80 -14
  53. data/lib/eco/api/session/config/people.rb +1 -17
  54. data/lib/eco/api/usecases.rb +2 -2
  55. data/lib/eco/api/usecases/base_case.rb +2 -2
  56. data/lib/eco/api/usecases/base_io.rb +17 -4
  57. data/lib/eco/api/usecases/default_cases.rb +2 -1
  58. data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +4 -4
  59. data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +223 -0
  60. data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +37 -0
  61. data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +2 -3
  62. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +11 -1
  63. data/lib/eco/api/usecases/default_cases/restore_db_case.rb +1 -2
  64. data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +1 -1
  65. data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +1 -1
  66. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +132 -29
  67. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +61 -36
  68. data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
  69. data/lib/eco/cli/config/default/input.rb +61 -8
  70. data/lib/eco/cli/config/default/options.rb +48 -17
  71. data/lib/eco/cli/config/default/people.rb +18 -24
  72. data/lib/eco/cli/config/default/people_filters.rb +3 -3
  73. data/lib/eco/cli/config/default/usecases.rb +97 -32
  74. data/lib/eco/cli/config/default/workflow.rb +22 -13
  75. data/lib/eco/cli/config/help.rb +1 -0
  76. data/lib/eco/cli/config/options_set.rb +106 -13
  77. data/lib/eco/cli/config/use_cases.rb +33 -33
  78. data/lib/eco/cli/scripting/args_helpers.rb +32 -5
  79. data/lib/eco/csv.rb +4 -2
  80. data/lib/eco/csv/table.rb +121 -21
  81. data/lib/eco/data.rb +1 -0
  82. data/lib/eco/data/crypto/encryption.rb +3 -3
  83. data/lib/eco/data/files/helpers.rb +6 -4
  84. data/lib/eco/data/fuzzy_match.rb +201 -0
  85. data/lib/eco/data/fuzzy_match/array_helpers.rb +75 -0
  86. data/lib/eco/data/fuzzy_match/chars_position_score.rb +38 -0
  87. data/lib/eco/data/fuzzy_match/ngrams_score.rb +82 -0
  88. data/lib/eco/data/fuzzy_match/pairing.rb +95 -0
  89. data/lib/eco/data/fuzzy_match/result.rb +87 -0
  90. data/lib/eco/data/fuzzy_match/results.rb +77 -0
  91. data/lib/eco/data/fuzzy_match/score.rb +49 -0
  92. data/lib/eco/data/fuzzy_match/stop_words.rb +35 -0
  93. data/lib/eco/data/fuzzy_match/string_helpers.rb +82 -0
  94. data/lib/eco/version.rb +1 -1
  95. metadata +147 -11
  96. data/lib/eco/api/microcases/refresh_abilities.rb +0 -19
  97. data/lib/eco/api/organization/presets_reference.json +0 -59
  98. data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +0 -30
@@ -1,19 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- # It sets the correct set of abilities based on the usergroups of `person`.
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
- def refresh_abilities(person, options)
8
- unless options.dig(:exclude, :account)
9
- if person.account
10
- unless options.dig(:exclude, :abilities) && !person.new?
11
- person.account.permissions_custom = session.new_preset(person)
12
- end
13
- end
14
- end
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,59 +0,0 @@
1
- {
2
- "read_only" : {
3
- "files": "browse",
4
- "data": "view",
5
- "reports": "view",
6
- "organization": null,
7
- "people": null,
8
- "person_core": null,
9
- "person_core_create": null,
10
- "person_core_edit": null,
11
- "person_account": null,
12
- "person_details": null,
13
- "pages": "view",
14
- "page_editor": null,
15
- "registers": "view"
16
- },
17
- "forms" : {
18
- "files": "browse",
19
- "data": "view",
20
- "reports": "view",
21
- "organization": null,
22
- "person_core": "attach",
23
- "person_core_create": null,
24
- "person_core_edit": null,
25
- "person_account": null,
26
- "person_details": "view",
27
- "pages": "create",
28
- "page_editor": "basic",
29
- "registers": "view"
30
- },
31
- "editor" : {
32
- "files": "browse",
33
- "data": "update",
34
- "reports": "edit",
35
- "organization": "view",
36
- "person_core": "view_people_manager",
37
- "person_core_create": null,
38
- "person_core_edit": null,
39
- "person_account": "view",
40
- "person_details": "view",
41
- "pages": "create",
42
- "page_editor": "intermediate",
43
- "registers": "view"
44
- },
45
- "administrator" : {
46
- "files": "administrate",
47
- "data": "administrate",
48
- "reports": "administrate",
49
- "organization": "administrate",
50
- "person_core": "view_people_manager",
51
- "person_core_create": "create",
52
- "person_core_edit": "edit",
53
- "person_account": "edit",
54
- "person_details": "edit_private",
55
- "pages": "administrate",
56
- "page_editor": "advanced",
57
- "registers": "dashboard"
58
- }
59
- }
@@ -1,30 +0,0 @@
1
- class Eco::API::UseCases::DefaultCases::RefreshAbilitiesCase < Eco::API::Common::Loaders::UseCase
2
- name "refresh-abilities"
3
- type :transform
4
-
5
- # Usecase to refresh the user's account abilities as defined in the org config for their usergroups.
6
- # @param people [Eco::API::Organization::People] target existing _People_ of the current update.
7
- # @param session [Eco::API::Session] the current session where the usecase kicks in.
8
- # @param options [Hash] the options that modify the case behaviour or bring some dependencies.
9
- # @return [Void]
10
- def main(people, session, options, usecase)
11
- users = require_users!(people, session.logger)
12
- update = session.new_job("main", "update", :update, usecase, :account)
13
- users.each do |person|
14
- person.account.permissions_custom = session.new_preset(person)
15
- update.add(person)
16
- end
17
- end
18
-
19
- private
20
-
21
- def require_users!(people, logger)
22
- people.users.tap do |users|
23
- unless users.length > 0
24
- logger.warn("There are no people with account amoung your #{people.length} people")
25
- exit(1)
26
- end
27
- end
28
- end
29
-
30
- end