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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e18955e051a52bf3b075eda58c3e4542cbaa47fad47a2c8be75531fc6ff7d60
4
- data.tar.gz: f73bc2e84b1502c0d07d0930822b84ed1850f24023ee579bf893abc9c9d5a1be
3
+ metadata.gz: 4252ad8eca24aa081cf86912ec2eb3e8a2417e9221d887700cb1f0572de62e62
4
+ data.tar.gz: ff3b1ebcaf7e3e234a3c0a787a10634050acdbf1af2366d1bd799ebf1eb3316b
5
5
  SHA512:
6
- metadata.gz: 373f6a6a0895abd0894f2d394dbe2b9e25fa00fda3ad6a9d50fa638a7259e0326ee2e23619803807075f448a2c98984a7804e95c4c15fe9263e6acb510f0033b
7
- data.tar.gz: 706933565f9eeafd437136ff9159bbe6feb201f07b5f3adf0775eb8c1dfe7069d6f3ca95d724b36fea75a9d355dd7679ded4e4693320455e177425c42b6c6154
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.66] - 2022-08-11
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.65] - 2022-08-11
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
- - Typo of a fix
20
+ - `Eco::API::Session::Config::Api`, the `org_id` is **not** a required parameter for `APIv2`
17
21
 
18
- ## [2.0.64] - 2022-08-11
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
- - Nothing
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.30', '< 0.9'
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:, mode: :local, root:, user_key: nil, external_key: nil)
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, mode: :local, user_key: nil, external_key: nil)
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
@@ -62,7 +62,7 @@ module Eco
62
62
  end
63
63
 
64
64
  def remote_folder
65
- File.join(*[base_path, enviro_subpath].compact)
65
+ [base_path, enviro_subpath].compact.join("/")
66
66
  end
67
67
  end
68
68
  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
@@ -0,0 +1,10 @@
1
+ module Eco
2
+ module API
3
+ class UseCases
4
+ module GraphQL
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative 'graphql/base'
@@ -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}"
@@ -164,3 +164,4 @@ require_relative 'usecases/use_case_io'
164
164
  require_relative 'usecases/default_cases'
165
165
  require_relative 'usecases/ooze_samples'
166
166
  require_relative 'usecases/ooze_cases'
167
+ require_relative 'usecases/graphql'
data/lib/eco/api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'ecoportal/api'
2
2
  require 'ecoportal/api-v2'
3
+ require 'ecoportal/api-graphql'
3
4
 
4
5
  module Eco
5
6
  module API
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
- data = to_rows_array(columns_array.transpose)
182
- self.class.new(data)
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
- out = super(data, **kargs, &block).reject do |row|
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
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.66"
2
+ VERSION = "2.0.68"
3
3
  end
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.66
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.30
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.30
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