eco-helpers 3.0.37 → 3.1.1
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +116 -1
- data/lib/eco/api/common/loaders/base.rb +2 -2
- data/lib/eco/api/common/loaders/case_base.rb +2 -0
- data/lib/eco/api/common/loaders/config/block.rb +78 -0
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +39 -7
- data/lib/eco/api/common/loaders/config.rb +3 -26
- data/lib/eco/api/common/loaders/error_handler.rb +2 -0
- data/lib/eco/api/common/loaders/parser.rb +1 -4
- data/lib/eco/api/common/people/entries.rb +23 -6
- data/lib/eco/api/common/people/entry_factory.rb +1 -1
- data/lib/eco/api/common/people/person_entry.rb +104 -27
- data/lib/eco/api/common/people/person_parser.rb +50 -16
- data/lib/eco/api/common/people/supervisor_helpers.rb +12 -6
- data/lib/eco/api/common/session/base_session.rb +75 -81
- data/lib/eco/api/common/session/environment.rb +49 -55
- data/lib/eco/api/common/session/file_manager.rb +132 -135
- data/lib/eco/api/common/session/helpers/prompt_user.rb +23 -30
- data/lib/eco/api/common/session/helpers.rb +10 -15
- data/lib/eco/api/common/session/logger/cache.rb +89 -96
- data/lib/eco/api/common/session/logger/channels.rb +24 -32
- data/lib/eco/api/common/session/logger/log.rb +38 -46
- data/lib/eco/api/common/session/logger.rb +50 -54
- data/lib/eco/api/common/session/mailer/aws_provider.rb +63 -71
- data/lib/eco/api/common/session/mailer/provider_base.rb +43 -48
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +101 -109
- data/lib/eco/api/common/session/mailer.rb +78 -83
- data/lib/eco/api/common/session/s3_uploader.rb +132 -138
- data/lib/eco/api/common/session/sftp.rb +202 -208
- data/lib/eco/api/common.rb +0 -3
- data/lib/eco/api/custom/mailer.rb +4 -2
- data/lib/eco/api/error/handlers.rb +1 -1
- data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +8 -2
- data/lib/eco/api/microcases/people/manage/search.rb +1 -1
- data/lib/eco/api/organization/people/similarity.rb +3 -3
- data/lib/eco/api/session/batch/base_policy.rb +42 -27
- data/lib/eco/api/session/batch/launcher/mode_size.rb +6 -1
- data/lib/eco/api/session/batch/launcher.rb +16 -3
- data/lib/eco/api/session/config/api.rb +4 -3
- data/lib/eco/api/session/config/apis/one_off.rb +1 -1
- data/lib/eco/api/session/config/files.rb +13 -12
- data/lib/eco/api/session/config/workflow.rb +1 -373
- data/lib/eco/api/session/config.rb +30 -9
- data/lib/eco/api/usecases/base_case/model.rb +6 -6
- data/lib/eco/api/usecases/base_case.rb +1 -1
- data/lib/eco/api/usecases/cli.rb +1 -1
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +8 -9
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -1
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
- data/lib/eco/api/usecases/lib/base/env.rb +21 -23
- data/lib/eco/api/usecases/lib/files/file_pattern.rb +41 -14
- data/lib/eco/api/usecases/lib/files/input_file.rb +110 -0
- data/lib/eco/api/usecases/lib/files/sftp.rb +5 -2
- data/lib/eco/api/usecases/lib/files.rb +1 -0
- data/lib/eco/api/usecases/lib/locations/base.rb +23 -0
- data/lib/eco/api/usecases/lib/locations/mapping.rb +94 -0
- data/lib/eco/api/usecases/lib/locations.rb +7 -0
- data/lib/eco/api/usecases/lib/people/base.rb +20 -0
- data/lib/eco/api/usecases/lib/people.rb +6 -0
- data/lib/eco/api/usecases/lib.rb +2 -0
- data/lib/eco/api/usecases/ooze_cases.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +1 -0
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +1 -0
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -0
- data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +8 -2
- data/lib/eco/api/usecases/service/sftp/with_target_config.rb +0 -33
- data/lib/eco/api/usecases/service/sftp.rb +7 -1
- data/lib/eco/api/usecases/use_case.rb +3 -2
- data/lib/eco/api/usecases/workflow.rb +5 -0
- data/lib/eco/api/usecases.rb +12 -5
- data/lib/eco/cli/scripting/args_helpers.rb +1 -9
- data/lib/eco/cli_default/options.rb +98 -68
- data/lib/eco/cli_default/workflow/end.rb +22 -0
- data/lib/eco/cli_default/workflow/launch_jobs.rb +14 -0
- data/lib/eco/cli_default/workflow/load/data.rb +27 -0
- data/lib/eco/cli_default/workflow/load/input.rb +28 -0
- data/lib/eco/cli_default/workflow/load.rb +13 -0
- data/lib/eco/cli_default/workflow/options.rb +10 -0
- data/lib/eco/cli_default/workflow/post_launch.rb +65 -0
- data/lib/eco/cli_default/workflow/report.rb +17 -0
- data/lib/eco/cli_default/workflow/rescued_exception.rb +21 -0
- data/lib/eco/cli_default/workflow/usecases.rb +23 -0
- data/lib/eco/cli_default/workflow.rb +24 -180
- data/lib/eco/data/count_trace.rb +51 -0
- data/lib/eco/data/files/content.rb +39 -0
- data/lib/eco/data/files/directory.rb +78 -45
- data/lib/eco/data/files/encoding.rb +12 -21
- data/lib/eco/data/files/file_pattern.rb +15 -8
- data/lib/eco/data/files/folder.rb +196 -0
- data/lib/eco/data/files/relative_path.rb +54 -0
- data/lib/eco/data/files/timestamp.rb +18 -0
- data/lib/eco/data/files.rb +46 -5
- data/lib/eco/data/fuzzy_match.rb +1 -1
- data/lib/eco/data/hashes/array_diff.rb +11 -5
- data/lib/eco/data/hashes/diff_result/meta.rb +12 -4
- data/lib/eco/data/locations/node_diff/accessors.rb +1 -1
- data/lib/eco/data/mapper.rb +5 -1
- data/lib/eco/data.rb +1 -0
- data/lib/eco/language/delegation/delegating_missing.rb +1 -1
- data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
- data/lib/eco/language/delegation/delegating_missing_on_class.rb +1 -1
- data/lib/eco/language/delegation/for_delegator/delegated_class.rb +1 -1
- data/lib/eco/language/klass/auto_loader.rb +129 -0
- data/lib/eco/language/klass/builder.rb +6 -6
- data/lib/eco/language/klass/const.rb +19 -0
- data/lib/eco/language/klass/helpers_built.rb +3 -1
- data/lib/eco/language/klass/hierarchy.rb +5 -1
- data/lib/eco/language/klass/naming.rb +5 -2
- data/lib/eco/language/klass/resolver.rb +21 -6
- data/lib/eco/language/klass/uid.rb +12 -0
- data/lib/eco/language/klass/when_inherited.rb +30 -6
- data/lib/eco/language/klass.rb +5 -2
- data/lib/eco/language/methods/access_modifier.rb +23 -0
- data/lib/eco/language/methods/instance_method_helpers.rb +6 -1
- data/lib/eco/language/methods.rb +1 -0
- data/lib/eco/language/models/hierarchy.rb +41 -0
- data/lib/eco/language/models/workflow.rb +385 -0
- data/lib/eco/language/models.rb +2 -1
- data/lib/eco/version.rb +1 -1
- metadata +31 -7
- data/lib/eco/api/common/class_auto_loader.rb +0 -114
- data/lib/eco/api/common/class_helpers.rb +0 -9
- data/lib/eco/api/common/class_hierarchy.rb +0 -45
- data/lib/eco/data/files/helpers.rb +0 -152
- data/lib/eco/language/models/class_helpers.rb +0 -136
@@ -1,6 +1,6 @@
|
|
1
1
|
ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
2
2
|
cnf.options_set do |options_set, top_opts| # rubocop:disable Metrics/BlockLength
|
3
|
-
options_set.add('--help', 'Offers a HELP') do |
|
3
|
+
options_set.add('--help', 'Offers a HELP') do |_opts, _sess|
|
4
4
|
conf = ASSETS.cli.config
|
5
5
|
|
6
6
|
active = proc do |opt|
|
@@ -54,6 +54,67 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
54
54
|
$stdout.reopen(file, 'w+')
|
55
55
|
end
|
56
56
|
|
57
|
+
desc = 'Runs in dry-run (no requests sent to server)'
|
58
|
+
options_set.add(['-dry-run', '-simulate'], desc) do |options, session|
|
59
|
+
options[:dry_run] = true
|
60
|
+
options[:simulate] = true
|
61
|
+
session.config.dry_run!
|
62
|
+
end
|
63
|
+
|
64
|
+
desc = 'Specifies the target API key space (i.e. uat, dev, etc.). '
|
65
|
+
desc << 'Use with CAUTION !!!'
|
66
|
+
options_set.add('-space', desc) do |options, _sess|
|
67
|
+
next unless (space = SCR.get_arg('-space', with_param: true))
|
68
|
+
|
69
|
+
options.deep_merge!(api: {space: space.to_sym})
|
70
|
+
end
|
71
|
+
|
72
|
+
desc = "It specifies the type of batch to be used (default: ':batch')"
|
73
|
+
options_set.add('-batch-mode', desc) do |options, session|
|
74
|
+
mode_in = SCR.get_arg('-batch-mode', with_param: true)
|
75
|
+
mode_str = mode_in.to_s.downcase
|
76
|
+
mode_sym = %i[batch job].find do |md|
|
77
|
+
next true if md.to_s == mode_str
|
78
|
+
|
79
|
+
md.to_s == mode_str.gsub(':', '')
|
80
|
+
end
|
81
|
+
|
82
|
+
unless mode_sym
|
83
|
+
session.log(:warn) {
|
84
|
+
"Unknown job_mode: #{mode_in}. Switching to default: ':batch'"
|
85
|
+
}
|
86
|
+
mode_sym = :batch
|
87
|
+
end
|
88
|
+
|
89
|
+
options.deep_merge!(workflow: {batch: {mode: mode_sym}})
|
90
|
+
end
|
91
|
+
|
92
|
+
# EMAIL NOTIFICATIONS & INVITES
|
93
|
+
|
94
|
+
desc = 'Prevent email to be sent'
|
95
|
+
options_set.add('-no-email', desc) do |options|
|
96
|
+
options.deep_merge!(workflow: {no_email: true})
|
97
|
+
end
|
98
|
+
|
99
|
+
desc = 'Do not prevent email notification when not in remote or when in dry run'
|
100
|
+
options_set.add('-notify', desc) do |options|
|
101
|
+
options.deep_merge!(workflow: {notify: true})
|
102
|
+
options.deep_merge!(workflow: {no_mail: false})
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
desc = 'Silence notifications on account creation or invites'
|
107
|
+
options_set.add(['-no-invites', '-exclude-invites'], desc) do |options|
|
108
|
+
options.merge!(send_invites: false)
|
109
|
+
end
|
110
|
+
|
111
|
+
desc = "People with account will be reinvited if they haven't accepted the invitation"
|
112
|
+
options_set.add('-send-invites', desc) do |options|
|
113
|
+
options.merge!(send_invites: true)
|
114
|
+
end
|
115
|
+
|
116
|
+
# CSV
|
117
|
+
|
57
118
|
desc = 'Skips the check of the headers'
|
58
119
|
options_set.add('-skip-header-check', desc) do |options, _sess|
|
59
120
|
options.deep_merge!(input: {header_check: {skip: true}})
|
@@ -69,26 +130,7 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
69
130
|
options.deep_merge!(input: {header_check: {must_be_valid: true}})
|
70
131
|
end
|
71
132
|
|
72
|
-
|
73
|
-
options_set.add('-schema-id', desc) do |options, session|
|
74
|
-
sch_name = SCR.get_arg('-schema-id', with_param: true)
|
75
|
-
sch_id = session.schemas.to_id(sch_name)
|
76
|
-
|
77
|
-
unless sch_id
|
78
|
-
msg = 'You need to specify a correct schema id or name. '
|
79
|
-
msg << "'#{sch_name}' does not exist. Correct options are: "
|
80
|
-
msg << session.schemas.map(&:name).join(', ')
|
81
|
-
|
82
|
-
session.log(:error) { msg }
|
83
|
-
exit(1)
|
84
|
-
end
|
85
|
-
|
86
|
-
options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
|
87
|
-
session.log(:info) {
|
88
|
-
"Setting schema #{session.schemas.to_name(sch_id)}"
|
89
|
-
}
|
90
|
-
session.schema = sch_id
|
91
|
-
end
|
133
|
+
# INPUT MODIFIERS
|
92
134
|
|
93
135
|
desc = 'Used to be used to specify the input file or folder when using -get-partial. '
|
94
136
|
desc << 'It can also be useful to obtain `-get-partial` of people base on `:export` use cases (i.e. -people-to-csv)'
|
@@ -98,11 +140,13 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
98
140
|
|
99
141
|
desc = 'Used to specify the input file encoding'
|
100
142
|
options_set.add('-input-encoding', desc) do |options, _sess|
|
101
|
-
if encoding = SCR.get_arg('-input-encoding', with_param: true)
|
143
|
+
if (encoding = SCR.get_arg('-input-encoding', with_param: true))
|
102
144
|
options.deep_merge!(input: {file: {encoding: encoding}})
|
103
145
|
end
|
104
146
|
end
|
105
147
|
|
148
|
+
# PEOPLE FETCH
|
149
|
+
|
106
150
|
desc = 'Do not load any people for this run.'
|
107
151
|
options_set.add('-no-people', desc) do |options, _sess|
|
108
152
|
options.deep_merge!(people: {
|
@@ -131,11 +175,6 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
131
175
|
})
|
132
176
|
end
|
133
177
|
|
134
|
-
desc = "Saves the requests's body even though running in dry-run (-simulate)"
|
135
|
-
options_set.add('-save-requests', desc) do |options, _sess|
|
136
|
-
options.deep_merge!(requests: {backup: true})
|
137
|
-
end
|
138
|
-
|
139
178
|
desc = 'Used to specify the cache file of people to be used. '
|
140
179
|
desc << 'It is useful to use as people reference those stored in cached file diffrent to the last one.'
|
141
180
|
options_set.add('-people-from-backup', desc) do |options, _sess|
|
@@ -156,46 +195,45 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
156
195
|
options.deep_merge!(report: {people: {csv: file}})
|
157
196
|
end
|
158
197
|
|
159
|
-
|
160
|
-
options_set.add(['-dry-run', '-simulate'], desc) do |options, session|
|
161
|
-
options[:dry_run] = true
|
162
|
-
options[:simulate] = true
|
163
|
-
session.config.dry_run!
|
164
|
-
end
|
165
|
-
|
166
|
-
desc = 'Specifies the target API key space (i.e. uat, dev, etc.). '
|
167
|
-
desc << 'Use with CAUTION !!!'
|
168
|
-
options_set.add('-space', desc) do |options, _sess|
|
169
|
-
next unless (space = SCR.get_arg('-space', with_param: true))
|
198
|
+
# Filter by schema
|
170
199
|
|
171
|
-
|
172
|
-
|
200
|
+
desc = 'Fix the current session to work with this schema'
|
201
|
+
options_set.add('-schema-id', desc) do |options, session|
|
202
|
+
sch_name = SCR.get_arg('-schema-id', with_param: true)
|
203
|
+
sch_id = session.schemas.to_id(sch_name)
|
173
204
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
mode_sym = %i[batch job].find do |md|
|
179
|
-
next true if md.to_s == mode_str
|
205
|
+
unless sch_id
|
206
|
+
msg = 'You need to specify a correct schema id or name. '
|
207
|
+
msg << "'#{sch_name}' does not exist. Correct options are: "
|
208
|
+
msg << session.schemas.map(&:name).join(', ')
|
180
209
|
|
181
|
-
|
210
|
+
session.log(:error) { msg }
|
211
|
+
exit(1)
|
182
212
|
end
|
183
213
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
214
|
+
options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
|
215
|
+
session.log(:info) {
|
216
|
+
"Setting schema #{session.schemas.to_name(sch_id)}"
|
217
|
+
}
|
218
|
+
session.schema = sch_id
|
219
|
+
end
|
190
220
|
|
191
|
-
|
221
|
+
# REQUESTS
|
222
|
+
|
223
|
+
desc = "Saves the requests's body even though running in dry-run (-simulate)"
|
224
|
+
options_set.add('-save-requests', desc) do |options, _sess|
|
225
|
+
options.deep_merge!(requests: {backup: true})
|
192
226
|
end
|
193
227
|
|
228
|
+
# WORKFLOW
|
229
|
+
|
194
230
|
desc = 'Runs runs post_launch cases even if in dry-run'
|
195
231
|
options_set.add('-run-postlaunch', desc) do |options, _sess|
|
196
232
|
options.deep_merge!(post_launch: {run: true})
|
197
233
|
end
|
198
234
|
|
235
|
+
# INCLUDED
|
236
|
+
|
199
237
|
desc = '(careful with this option) This will include everybody as part of the update '
|
200
238
|
desc << '(including those that are api excluded). '
|
201
239
|
desc << 'Only launch with this option when only api excluded people are included in your update.'
|
@@ -208,6 +246,8 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
208
246
|
options.deep_merge!(include: {excluded: {only: true}})
|
209
247
|
end
|
210
248
|
|
249
|
+
# BATCH POLCIY & API POLICIES
|
250
|
+
|
211
251
|
desc = 'Ignores threshold limitations on requests for this session (skip batch belt)'
|
212
252
|
options_set.add('-skip-batch-policy', desc) do |options|
|
213
253
|
options.deep_merge!(skip: {batch_policy: true})
|
@@ -218,10 +258,14 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
218
258
|
options.deep_merge!(skip: {api_policies: true})
|
219
259
|
end
|
220
260
|
|
261
|
+
# FEEDBACK
|
262
|
+
|
221
263
|
options_set.add('-feed-only-stats', 'Shows only stats when giving feedback') do |options|
|
222
264
|
options.deep_merge!(feedback: {only_stats: true})
|
223
265
|
end
|
224
266
|
|
267
|
+
# STRICT/SOFT SEARCH MATCH
|
268
|
+
|
225
269
|
desc = "Force search mode to 'strict' when pairing input entries with existing people."
|
226
270
|
desc << ' Besides id and external_id it will not try to find by email unless external_id is not specified'
|
227
271
|
options_set.add('-search-strict', desc) do |options|
|
@@ -238,20 +282,6 @@ ASSETS.cli.config do |cnf| # rubocop:disable Metrics/BlockLength
|
|
238
282
|
})
|
239
283
|
end
|
240
284
|
|
241
|
-
desc = 'Prevent email to be sent (experimental)'
|
242
|
-
options_set.add('-no-email', desc) do |options|
|
243
|
-
options.deep_merge!(workflow: {no_email: true})
|
244
|
-
end
|
245
|
-
|
246
|
-
desc = 'Silence notifications on account creation or invites'
|
247
|
-
options_set.add(['-no-invites', '-exclude-invites'], desc) do |options|
|
248
|
-
options.merge!(send_invites: false)
|
249
|
-
end
|
250
|
-
desc = "People with account will be reinvited if they haven't accepted the invitation"
|
251
|
-
options_set.add('-send-invites', desc) do |options|
|
252
|
-
options.merge!(send_invites: true)
|
253
|
-
end
|
254
|
-
|
255
285
|
# EXCLUDE CORE
|
256
286
|
|
257
287
|
options_set.add('-exclude-core', 'Core input data is not used on the update') do |options|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class End < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :end) do
|
4
|
+
on(:end) do
|
5
|
+
get_people = options.dig(:people, :get)
|
6
|
+
partial_update = get_people && get_people[:type] == :partial
|
7
|
+
|
8
|
+
unless !options[:end_get] || options[:dry_run] || partial_update
|
9
|
+
if !some_update_case?(io)
|
10
|
+
# Prevent getting people when there were no use cases that used them
|
11
|
+
log(:info) {
|
12
|
+
"Won't be recaching people, as there haven't been any targetted updates"
|
13
|
+
}
|
14
|
+
elsif !people
|
15
|
+
people = session.micro.people_cache
|
16
|
+
io.new(data: people)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class LaunchJobs < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :launch_jobs) do
|
4
|
+
before(:launch_jobs) do
|
5
|
+
available_args = cli.config.available_option_args
|
6
|
+
SCR.stop_on_unknown!(all_available: available_args)
|
7
|
+
end
|
8
|
+
|
9
|
+
on(:launch_jobs) do
|
10
|
+
session.jobs_launch(simulate: options[:dry_run])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Eco::CliDefault::Workflow::Load
|
2
|
+
class Data < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :load, :data) do
|
4
|
+
with(:load) do |wf_load|
|
5
|
+
wf_load.before(:data) do
|
6
|
+
# @todo model should be set to the target model
|
7
|
+
# based on the main use case that requires data!
|
8
|
+
io.new(model: :people)
|
9
|
+
end
|
10
|
+
|
11
|
+
wf_load.with(:data) do |wf_peo|
|
12
|
+
wf_peo.on(:get) do
|
13
|
+
next unless some_data_case?(io) || options.dig(:people, :get)
|
14
|
+
|
15
|
+
io.new(data: cli.config.people(io: io))
|
16
|
+
end
|
17
|
+
|
18
|
+
wf_peo.on(:filter) do
|
19
|
+
next unless data && !data.empty?
|
20
|
+
|
21
|
+
io.new(data: cli.config.people_filters.process(io: io))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Eco::CliDefault::Workflow::Load
|
2
|
+
class Input < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :load, :input) do
|
4
|
+
with(:load) do |wf_load|
|
5
|
+
wf_load.with(:input) do |wf_in|
|
6
|
+
wf_in.on(:get) do
|
7
|
+
input_is_required = some_input_case?(io) || options.dig(:input, :entries_from)
|
8
|
+
missing_input = !input || input.empty?
|
9
|
+
next unless missing_input && input_is_required
|
10
|
+
|
11
|
+
if options.dig(:input, :entries_from)
|
12
|
+
io.new(input: cli.config.input.get(io: io))
|
13
|
+
else
|
14
|
+
opt_case = cli_input_cases(io).values.first.option
|
15
|
+
io.new(input: cli.config.input.get(io: io, option: opt_case))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
wf_in.on(:filter) do
|
20
|
+
next unless input && !input.empty?
|
21
|
+
|
22
|
+
io.new(input: cli.config.input_filters.process(io: io))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class Load < Eco::API::Common::Loaders::Workflow
|
3
|
+
require_relative 'load/input'
|
4
|
+
require_relative 'load/data'
|
5
|
+
|
6
|
+
[
|
7
|
+
Input,
|
8
|
+
Data
|
9
|
+
].each do |wf_config|
|
10
|
+
wf_config.config_copy(to: self, all: true)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class PostLaunch < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :post_launch) do
|
4
|
+
before(:post_launch) do |wf_post|
|
5
|
+
next wf_post.skip! if session.post_launch.empty?
|
6
|
+
|
7
|
+
run_it = !options[:dry_run] || options.dig(:post_launch, :run)
|
8
|
+
unless run_it
|
9
|
+
wf_post.skip!
|
10
|
+
|
11
|
+
log(:info) {
|
12
|
+
msg = 'Although there are post_launch cases, they will NOT be RUN'
|
13
|
+
msg << ', because we are in dry-run (simulate).' if options[:dry_run]
|
14
|
+
msg
|
15
|
+
}
|
16
|
+
|
17
|
+
next
|
18
|
+
end
|
19
|
+
|
20
|
+
get_people = options.dig(:people, :get)
|
21
|
+
partial_update = get_people && get_people[:type] == :partial
|
22
|
+
refresh_data = !options[:dry_run] && partial_update
|
23
|
+
|
24
|
+
unless refresh_data
|
25
|
+
log(:info) {
|
26
|
+
msg = 'Although there are post_launch cases, data will not be refreshed before their run'
|
27
|
+
if io.options[:dry_run]
|
28
|
+
msg << ', because we are in dry-run (simulate).'
|
29
|
+
elsif !partial_update
|
30
|
+
msg << ', because it is not a partial update (-get-partial option not present).'
|
31
|
+
end
|
32
|
+
msg
|
33
|
+
}
|
34
|
+
|
35
|
+
next
|
36
|
+
end
|
37
|
+
|
38
|
+
# get target people afresh
|
39
|
+
peo_aux = session.micro.people_refresh(
|
40
|
+
people: data,
|
41
|
+
include_created: true
|
42
|
+
)
|
43
|
+
io.base.new(data: peo_aux)
|
44
|
+
end
|
45
|
+
|
46
|
+
with(:post_launch) do |wf_post|
|
47
|
+
wf_post.on(:usecases) do |_wf_pu, io|
|
48
|
+
session.post_launch.each do |use|
|
49
|
+
use.launch(io: io).base
|
50
|
+
rescue Eco::API::UseCases::BaseIO::MissingParameter => err
|
51
|
+
raise unless err.required == :people
|
52
|
+
|
53
|
+
log(:debug) {
|
54
|
+
"Skipping use case '#{use.name}' -- no base people detected for the current run"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
wf_post.on(:launch_jobs) do |_wf_pl, _io|
|
60
|
+
session.jobs_launch(simulate: options[:dry_run])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class Report < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :report) do
|
4
|
+
on(:report) do |_wf_rep, io|
|
5
|
+
if (file = options.dig(:report, :people, :csv))
|
6
|
+
options.deep_merge!(export: {
|
7
|
+
options: {internal_names: true, nice_header: true, split_schemas: true},
|
8
|
+
file: {name: file, format: :csv}
|
9
|
+
})
|
10
|
+
|
11
|
+
aux_io = io.new(data: data.updated_or_created)
|
12
|
+
session.process_case('to-csv', io: aux_io, type: :export)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class RescuedException < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :exception) do
|
4
|
+
class << self
|
5
|
+
attr_accessor :rescued
|
6
|
+
end
|
7
|
+
|
8
|
+
# default rescue
|
9
|
+
exception do |err, io|
|
10
|
+
next io if rescued
|
11
|
+
|
12
|
+
self.rescued = true
|
13
|
+
log(:debug) { err.patch_full_message }
|
14
|
+
|
15
|
+
workflow.run(:close, io: io)
|
16
|
+
rescue StandardError => err
|
17
|
+
puts "Some problem in workflow.rescue: #{err}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Eco::CliDefault::Workflow
|
2
|
+
class Usecases < Eco::API::Common::Loaders::Workflow
|
3
|
+
config_block(:workflow, :usecases) do
|
4
|
+
before(:usecases) do
|
5
|
+
# save partial entries -> should be native to session.workflow
|
6
|
+
get_people = options.dig(:people, :get)
|
7
|
+
partial_update = get_people && get_people[:type] == :partial
|
8
|
+
|
9
|
+
if !options[:dry_run] && partial_update
|
10
|
+
partial_file = session.config.people.partial_cache
|
11
|
+
session.file_manager.save_json(io.data, partial_file, :timestamp)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
on(:usecases) do
|
16
|
+
next if cli_usecases.process(io: io)
|
17
|
+
|
18
|
+
log(:info) { 'No update operation specified... quitting' }
|
19
|
+
exit 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|