eco-helpers 2.0.66 → 2.0.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -7
- data/eco-helpers.gemspec +2 -1
- data/lib/eco/api/session/config/api.rb +28 -4
- data/lib/eco/api/session/config/apis.rb +7 -2
- data/lib/eco/api/session/config/sftp.rb +1 -1
- data/lib/eco/api/usecases/graphql/base.rb +26 -0
- data/lib/eco/api/usecases/graphql.rb +10 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +17 -0
- data/lib/eco/api/usecases.rb +1 -0
- data/lib/eco/api.rb +1 -0
- data/lib/eco/csv/table.rb +8 -3
- data/lib/eco/csv.rb +2 -17
- data/lib/eco/version.rb +1 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4252ad8eca24aa081cf86912ec2eb3e8a2417e9221d887700cb1f0572de62e62
|
4
|
+
data.tar.gz: ff3b1ebcaf7e3e234a3c0a787a10634050acdbf1af2366d1bd799ebf1eb3316b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f8f9ef76245e0ee390b8f9118ace7cf46cb071699d94b8dd56591e0df11314a81ba0e83d688e64e6a53d3cfba510de8be5559a4ed948a13806baa14d69e9d80
|
7
|
+
data.tar.gz: e3ed91fb997fe84596ae2775b5841637eaf70173c2c1767290c10fceef0a9b3417c66c2f17ff46459558ca1f21ae81f248a60e0fd977642b9c8d30acb2dcec63
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,51 @@
|
|
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.69] - 2022-09-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
|
-
- `Eco::API::UseCases::DefaultCases::Samples::Sftp` manage exception when trying to access remote folder
|
10
9
|
|
11
|
-
## [2.0.
|
10
|
+
## [2.0.68] - 2022-09-19
|
12
11
|
|
13
12
|
### Added
|
13
|
+
- `Eco::API::UseCases::OozeSamples::OozeBaseCase`: **added** a couple of functions to support **page creation**: `#new_page` and `#create_page`
|
14
|
+
|
14
15
|
### Changed
|
16
|
+
- upgraded **dependency** to `ecoportal-api-graphql` **gem**
|
17
|
+
- upgraded **dependency** to `ecoportal-api-v2` **gem**
|
18
|
+
|
15
19
|
### Fixed
|
16
|
-
-
|
20
|
+
- `Eco::API::Session::Config::Api`, the `org_id` is **not** a required parameter for `APIv2`
|
17
21
|
|
18
|
-
## [2.0.
|
22
|
+
## [2.0.67] - 2022-09-15
|
23
|
+
|
24
|
+
### Added
|
25
|
+
- **dependency** to `ecoportal-api-graphql` **gem**
|
26
|
+
- Added integration for `GraphQL`
|
27
|
+
- `session.api(version: :graphql)`
|
28
|
+
- New base case `Eco::API::UseCases::GraphQL::Base` to create `GraphQL` use cases
|
19
29
|
|
20
30
|
### Changed
|
21
|
-
-
|
31
|
+
- `Eco::CSV#read` and `Eco::CSV#parse` delegating `nil` row removal to sublcass `Eco::CSV::Table`
|
32
|
+
- **upgraded** dependency on `ecoportal-api-v2`
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
- `Eco::API::Session::Config::SFTP#remote_folder` to have path separator always as `/`
|
36
|
+
- `Eco::CSV::Table`
|
37
|
+
- to delete rows with all `nil` values
|
38
|
+
- to keep `header` when file comes only with `header` row (with `0` count)
|
39
|
+
|
40
|
+
## [2.0.66] - 2022-08-11
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
- `Eco::API::UseCases::DefaultCases::Samples::Sftp` manage exception when trying to access remote folder
|
44
|
+
|
45
|
+
## [2.0.65] - 2022-08-11
|
46
|
+
|
47
|
+
### Fixed
|
48
|
+
- Typo of a fix
|
22
49
|
|
23
50
|
## [2.0.63] - 2022-08-11
|
24
51
|
|
@@ -32,7 +59,6 @@ All notable changes to this project will be documented in this file.
|
|
32
59
|
- `Eco::API::Common::Session::Sftp` fetches from config
|
33
60
|
- `Eco::API::Session::Config::Sftp#password`
|
34
61
|
|
35
|
-
### Changed
|
36
62
|
### Fixed
|
37
63
|
- `Eco::API::UseCases::DefaultCases::CreateCase` had a typo
|
38
64
|
|
data/eco-helpers.gemspec
CHANGED
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.8.5', '< 0.9'
|
34
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.
|
34
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.8.32', '< 0.9'
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.6', '< 0.2'
|
35
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
36
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
37
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
|
@@ -12,6 +12,8 @@ module Eco
|
|
12
12
|
:v1
|
13
13
|
when :v2, :oozes
|
14
14
|
:v2
|
15
|
+
when :graphql
|
16
|
+
:graphql
|
15
17
|
else # :internal, :v0
|
16
18
|
:v0
|
17
19
|
end
|
@@ -25,13 +27,17 @@ module Eco
|
|
25
27
|
Ecoportal::API::V1
|
26
28
|
when :v2
|
27
29
|
Ecoportal::API::V2
|
30
|
+
when :graphql
|
31
|
+
Ecoportal::API::GraphQL
|
28
32
|
else
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
end
|
33
37
|
|
34
|
-
def initialize(name, key:, host:, version:,
|
38
|
+
def initialize(name, root:, key:, host:, version:,
|
39
|
+
mode: :local, user_key: nil, external_key: nil,
|
40
|
+
email: nil, pass: nil, org_id: nil)
|
35
41
|
super(nil)
|
36
42
|
@root = root
|
37
43
|
@apis = {}
|
@@ -42,6 +48,9 @@ module Eco
|
|
42
48
|
self["mode"] = mode
|
43
49
|
self["user_key"] = user_key
|
44
50
|
self["external_key"] = external_key
|
51
|
+
self["email"] = email
|
52
|
+
self["pass"] = pass
|
53
|
+
self["org_id"] = org_id
|
45
54
|
end
|
46
55
|
|
47
56
|
# @return [Eco::API::Session::Config] the `root` config
|
@@ -103,6 +112,18 @@ module Eco
|
|
103
112
|
(version == :v0) && self["key"]
|
104
113
|
end
|
105
114
|
|
115
|
+
def org_id
|
116
|
+
self["org_id"]
|
117
|
+
end
|
118
|
+
|
119
|
+
def email
|
120
|
+
self["email"]
|
121
|
+
end
|
122
|
+
|
123
|
+
def pass
|
124
|
+
self["pass"]
|
125
|
+
end
|
126
|
+
|
106
127
|
def host
|
107
128
|
self["host"]
|
108
129
|
end
|
@@ -147,10 +168,12 @@ module Eco
|
|
147
168
|
klass.new(external_key, host: host, logger: logger)
|
148
169
|
when :v2
|
149
170
|
klass.new(user_key: user_key, org_key: external_key, host: host, logger: logger)
|
171
|
+
when :graphql
|
172
|
+
klass.new(org_id: org_id, email: email, pass: pass)
|
150
173
|
end.tap do |api|
|
151
174
|
unless !api || log_connection?
|
152
175
|
@logger.info("Created api#{self.version(version)} connection on '#{name}' enviro, pointing to '#{host}' in '#{mode}' mode")
|
153
|
-
api.logger.level = ::Logger::UNKNOWN
|
176
|
+
api.logger.level = ::Logger::UNKNOWN if api.respond_to?(:logger)
|
154
177
|
end
|
155
178
|
end
|
156
179
|
end
|
@@ -163,14 +186,15 @@ module Eco
|
|
163
186
|
when :v1
|
164
187
|
external_key && host
|
165
188
|
when :v2
|
166
|
-
external_key && user_key
|
189
|
+
external_key && user_key && host
|
190
|
+
when :graphql
|
191
|
+
email && pass && org_id && host
|
167
192
|
end
|
168
193
|
end
|
169
194
|
|
170
195
|
def log_connection?
|
171
196
|
config.logger.log_connection?
|
172
197
|
end
|
173
|
-
|
174
198
|
end
|
175
199
|
end
|
176
200
|
end
|
@@ -26,7 +26,9 @@ module Eco
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def add(name, key:, host:, version: :internal,
|
29
|
+
def add(name, key:, host:, version: :internal,
|
30
|
+
mode: :local, user_key: nil, external_key: nil,
|
31
|
+
email: nil, pass: nil, org_id: nil)
|
30
32
|
apis[name] = Session::Config::Api.new(
|
31
33
|
name,
|
32
34
|
key: key,
|
@@ -35,7 +37,10 @@ module Eco
|
|
35
37
|
mode: mode,
|
36
38
|
root: self,
|
37
39
|
user_key: user_key,
|
38
|
-
external_key: external_key
|
40
|
+
external_key: external_key,
|
41
|
+
email: email,
|
42
|
+
pass: pass,
|
43
|
+
org_id: org_id
|
39
44
|
)
|
40
45
|
self
|
41
46
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Eco::API::UseCases::GraphQL::Base < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "graphql-base"
|
3
|
+
type :other
|
4
|
+
|
5
|
+
attr_reader :session, :options, :usecase
|
6
|
+
|
7
|
+
def main(session, options, usecase)
|
8
|
+
options[:end_get] = false
|
9
|
+
@session = session; @options = options; @usecase = usecase
|
10
|
+
process
|
11
|
+
end
|
12
|
+
|
13
|
+
# Write here your script
|
14
|
+
def process
|
15
|
+
raise "You need to inherit from this class ('#{self.class}') and call super with a block"
|
16
|
+
end
|
17
|
+
|
18
|
+
def graphql
|
19
|
+
@graphql ||= session.api(version: :graphql)
|
20
|
+
end
|
21
|
+
|
22
|
+
def exit_error(msg)
|
23
|
+
logger.error(msg)
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
end
|
@@ -29,6 +29,23 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
|
|
29
29
|
|
30
30
|
protected
|
31
31
|
|
32
|
+
def new_page(template_id)
|
33
|
+
apiv2.pages.get_new(template_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_page(page = nil, template_id: nil, retrieve: false)
|
37
|
+
template_id = template_id.id if template_id.is_a?(Ecoportal::API::V2::Page)
|
38
|
+
template_id ||= page.template_id if page.respond_to?(:template_id)
|
39
|
+
template_id ||= page["template_id"] if page.is_a?(Hash)
|
40
|
+
page = new_page(template_id) unless page || !template_id
|
41
|
+
yield(page) if block_given?
|
42
|
+
reference = apiv2.pages.create(page, from: template_id)
|
43
|
+
ooze_id = reference.page_id
|
44
|
+
stage_id = reference.active_stage_id
|
45
|
+
return [ooze_id, stage_id] unless retrieve
|
46
|
+
ooze(ooze_id, stage_id: stage_id)
|
47
|
+
end
|
48
|
+
|
32
49
|
def add_field_by_doc(doc, section, after: nil, before: nil, side: :left)
|
33
50
|
unless section.is_a?(Ecoportal::API::V2::Page::Section)
|
34
51
|
raise "You need to specify a section for a new field. Given: #{section.class}"
|
data/lib/eco/api/usecases.rb
CHANGED
data/lib/eco/api.rb
CHANGED
data/lib/eco/csv/table.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Eco
|
2
2
|
class CSV
|
3
3
|
class Table < ::CSV::Table
|
4
|
-
|
5
4
|
# @param input [Array<Row>, Array<Array>, Eco::CSV::Table, ::CSV::Table]
|
6
5
|
# - when `Array<Array>` => all `rows` as arrays where first array is the **header**
|
7
6
|
def initialize(input)
|
8
7
|
super(to_rows_array(input))
|
8
|
+
self.delete_if do |row|
|
9
|
+
values = row.fields
|
10
|
+
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
# @return [Hash] where keys are the groups and the values a `Eco::CSV::Table`
|
@@ -178,8 +181,9 @@ module Eco
|
|
178
181
|
private
|
179
182
|
|
180
183
|
def columns_to_table(columns_array)
|
181
|
-
|
182
|
-
self.class.new(
|
184
|
+
rows_data = columns_array.transpose
|
185
|
+
return self.class.new(rows_data) if rows_data.length > 0
|
186
|
+
raise ArgumentError.new("Expecting 'columns_array' to at least have header. Given: #{columns_array}")
|
183
187
|
end
|
184
188
|
|
185
189
|
def to_rows_array(data)
|
@@ -200,6 +204,7 @@ module Eco
|
|
200
204
|
data
|
201
205
|
when Array
|
202
206
|
headers = data.shift
|
207
|
+
data.push(Array.new(headers.length)) if data.count == 0
|
203
208
|
data.map do |arr_row|
|
204
209
|
::CSV::Row.new(headers, arr_row)
|
205
210
|
end.compact
|
data/lib/eco/csv.rb
CHANGED
@@ -8,34 +8,19 @@ module Eco
|
|
8
8
|
# @return [Eco::CSV::Table]
|
9
9
|
def parse(data, **kargs, &block)
|
10
10
|
kargs = {headers: true, skip_blanks: true}.merge(kargs)
|
11
|
-
|
12
|
-
values = row.to_hash.values
|
13
|
-
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
14
|
-
end
|
15
|
-
Eco::CSV::Table.new(out)
|
11
|
+
Eco::CSV::Table.new(super(data, **kargs, &block))
|
16
12
|
end
|
17
13
|
|
18
14
|
# @return [Eco::CSV::Table]
|
19
15
|
def read(file, **kargs)
|
20
16
|
kargs = {headers: true, skip_blanks: true}.merge(kargs)
|
21
|
-
|
22
17
|
args = [file].tap do |arg|
|
23
18
|
encoding = Eco::API::Common::Session::FileManager.encoding(file)
|
24
|
-
#encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
|
25
|
-
#arg.push(encoding)
|
26
19
|
arg.push("rb:bom|utf-8") if encoding == "bom"
|
27
20
|
end
|
28
|
-
|
29
|
-
out = super(*args, **kargs).reject do |row|
|
30
|
-
values = row.to_hash.values
|
31
|
-
values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?)
|
32
|
-
end
|
33
|
-
Eco::CSV::Table.new(out)
|
21
|
+
Eco::CSV::Table.new(super(*args, **kargs))
|
34
22
|
end
|
35
|
-
|
36
23
|
end
|
37
|
-
|
38
|
-
|
39
24
|
end
|
40
25
|
end
|
41
26
|
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.8.
|
139
|
+
version: 0.8.32
|
140
140
|
- - "<"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0.9'
|
@@ -146,10 +146,30 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.8.
|
149
|
+
version: 0.8.32
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ecoportal-api-graphql
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.6
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0.2'
|
163
|
+
type: :runtime
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 0.1.6
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.2'
|
153
173
|
- !ruby/object:Gem::Dependency
|
154
174
|
name: aws-sdk-s3
|
155
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -565,6 +585,8 @@ files:
|
|
565
585
|
- lib/eco/api/usecases/default_cases/update_case.rb
|
566
586
|
- lib/eco/api/usecases/default_cases/update_details_case.rb
|
567
587
|
- lib/eco/api/usecases/default_cases/upsert_case.rb
|
588
|
+
- lib/eco/api/usecases/graphql.rb
|
589
|
+
- lib/eco/api/usecases/graphql/base.rb
|
568
590
|
- lib/eco/api/usecases/ooze_cases.rb
|
569
591
|
- lib/eco/api/usecases/ooze_cases/export_register_case.rb
|
570
592
|
- lib/eco/api/usecases/ooze_samples.rb
|