dina 1.3.0.0 → 1.3.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36ae9a46adaaf1a545511c102afbc5bada1c3ad4632273672253f9191e347459
4
- data.tar.gz: 67c1631fad9d7ebb3469a063fc6b22e1d6c9d720a8abe6804ae35c7d4dd83848
3
+ metadata.gz: 38688424689df19ac817a13a5f0ef0a1d70ffc75e300f124adee33769faf0be3
4
+ data.tar.gz: 7e93423153af45f71614d6536fc79dcd7bdb19c1373c515a18927d6cecce08af
5
5
  SHA512:
6
- metadata.gz: ba219ae94560f594838864568429f8c84e4bf86a8c4396a0fd142c8803a0aea03f0da864b7bb9b44f700234d1da7dfbf9b75e6033ad1690fb5b13e69785700b1
7
- data.tar.gz: cd564fa3198356107742862c2cc7d45b4c32dace7c3684117ccb9e29d97e066bb0c6fb60dd5ca8aa388afe66c11203fa9d6558efc9f68ee82824536aa076ef4d
6
+ metadata.gz: 735f7adff9ef6397b5a4e474b1985c8818d948df5160fbc4f121c2b32b1c65c8d3029d3478a9011bb89921ab7f0719d562c32e79b47a6717b4464bdba295fb41
7
+ data.tar.gz: 6dfc825b17ef3f55cc98298816982de34d19c9fa41c3bf25d56d0b85f82e1714040968210d2f00e7e2e33a579ec8684f6987d9b4f2d30ab934be43b8dda238b1
@@ -29,6 +29,7 @@ module Dina
29
29
  # endpoint_url: "DINA API URL without terminating slash",
30
30
  # authorization_url: "Keycloak authorization URL without terminating slash".
31
31
  # realm: "provided by DINA admin in Keycloak"
32
+ # verify_ssl: true
32
33
  # }
33
34
  #
34
35
  # @param options [Hash] the configuration options
@@ -51,6 +52,10 @@ module Dina
51
52
  Keycloak.auth_server_url = config.authorization_url
52
53
  Keycloak.realm = config.realm
53
54
 
55
+ if opts[:verify_ssl] && opts[:verify_ssl] == false
56
+ Dina::BaseModel.connection_options[:ssl] = { verify: false }
57
+ end
58
+
54
59
  if ::File.zero?(config.token_store_file)
55
60
  save_token(hash: empty_token)
56
61
  end
@@ -4,11 +4,11 @@ require_rel 'search_connection'
4
4
  #TODO: requires testing, likely failing
5
5
 
6
6
  module Dina
7
- class SearchAutocomplete < BaseModel
7
+ class SearchAutoComplete < BaseModel
8
8
 
9
9
  self.connection_class = SearchConnection
10
10
 
11
- custom_endpoint :execute, on: :collection, request_method: :post
11
+ custom_endpoint :execute, on: :collection, request_method: :get
12
12
 
13
13
  def self.endpoint_path
14
14
  "search-api/search-ws/"
@@ -34,11 +34,12 @@ module Dina
34
34
  end
35
35
 
36
36
  def run(request_method, path, params: nil, headers: {}, body: nil)
37
- #TODO: works for search class, but likely failing for autocomplete, count, and mapping
38
- params = {
39
- indexName: index_name(index: body[:index])
40
- }
41
37
  path.slice!("/execute")
38
+ if params && params.has_key?(:index)
39
+ params.merge!(indexName: index_name(index: params[:index]))
40
+ elsif body && body.has_key?(:index)
41
+ params = { indexName: index_name(index: body[:index]) }
42
+ end
42
43
  payload = JSON.generate(body[:payload]) rescue ""
43
44
 
44
45
  response = faraday.run_request(request_method, path, body, headers) do |request|
@@ -48,7 +49,16 @@ module Dina
48
49
  end
49
50
 
50
51
  attributes = response.body.dup
51
- response.body["meta"] = {}
52
+ meta = {}
53
+ if attributes.has_key?("hits")
54
+ #TODO: does not work with SearchAutoComplete because response is different from Search
55
+ meta["count"] = attributes["hits"]["total"]["value"] rescue 0
56
+ elsif attributes.has_key?("count")
57
+ meta["count"] = attributes["count"]
58
+ elsif attributes.has_key?("attributes")
59
+ meta = attributes
60
+ end
61
+ response.body["meta"] = meta
52
62
  response.body["errors"] = []
53
63
  response.body["data"] = attributes["hits"]["hits"].map{|d| d["_source"]["data"]} rescue []
54
64
  response
@@ -1,8 +1,6 @@
1
1
  require_rel '../models/base_model'
2
2
  require_rel 'search_connection'
3
3
 
4
- #TODO: requires testing, likely failing
5
-
6
4
  module Dina
7
5
  class SearchCount < BaseModel
8
6
 
@@ -1,8 +1,6 @@
1
1
  require_rel '../models/base_model'
2
2
  require_rel 'search_connection'
3
3
 
4
- #TODO: requires testing, likely failing
5
-
6
4
  module Dina
7
5
  class SearchMapping < BaseModel
8
6
 
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- PATCH = 0
6
+ PATCH = 2
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
@@ -0,0 +1,14 @@
1
+ # Keycloak Client depends on RestClient & so verifying SSL must be accommodate here
2
+
3
+ module RestClient
4
+ class Request
5
+ orig_initialize = instance_method(:initialize)
6
+
7
+ define_method(:initialize) do |args|
8
+ if Dina.config.verify_ssl == false
9
+ args[:verify_ssl] = false
10
+ orig_initialize.bind(self).(args)
11
+ end
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.0
4
+ version: 1.3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-12-04 00:00:00.000000000 Z
12
+ date: 2023-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_api_client
@@ -211,6 +211,7 @@ files:
211
211
  - lib/dina/utils/multi_lingual_title.rb
212
212
  - lib/dina/utils/validator.rb
213
213
  - lib/dina/version.rb
214
+ - lib/rest_client_request_patch.rb
214
215
  homepage: https://github.com/dshorthouse/dina
215
216
  licenses:
216
217
  - MIT