algolia 3.42.2 → 3.42.3

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: d61077a66bcc7105679f9ed7dcd6b1a4a4ed67b5f10e751604d271382b300a70
4
- data.tar.gz: 808ddcec7d187c1a992dc0be37f3b1bc595b1e533b30a9cd6909946a36e041b9
3
+ metadata.gz: c7ee727296f4ef0f5097f1e9a17f8b76e0a2e04303aeaaa1b84a78a8cc3e899e
4
+ data.tar.gz: 340f56004e8c495e8585bf43dc0b5a8cf36208c69b239b3d029e7b6b9428e8b7
5
5
  SHA512:
6
- metadata.gz: c944074227fd43acaf224ead099d48c079316bf98a66afa793e1ac7b84810a0f5a1823f5433ec488df788c2a4cc10efdf4d29134f53f6541f508f4ee359d4637
7
- data.tar.gz: 1386f223055c7d8a511283a94647ac8c27995451584c12febb9211d6f6ccee1c42faa2cc59fe24b069bafa64847de6d826d8ec8c971f2ebd5d302c627c1a7b7c
6
+ metadata.gz: 0c50e49997bdfb4101478f6800ce76397c73d51e7755a1c7c425e6c6565d7c4435c04d792707fbee1c1cc3efc7a7cc8ef2fea740312d579651338c4cac953563
7
+ data.tar.gz: 2d38395ca0ec5f708b0ba6a3210ff2c60d988829aac5cf80b8de2e767f408722932c899e86902555df17d064569612d9bf86ed5f115f9ee4f6bdff3c1b8a6821
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [3.42.3](https://github.com/algolia/algoliasearch-client-ruby/compare/3.42.2...3.42.3)
2
+
3
+ - [772f7055cc](https://github.com/algolia/api-clients-automation/commit/772f7055cc) fix(clients): add warning in replace_all_objects for empty objects ([#6610](https://github.com/algolia/api-clients-automation/pull/6610)) by [@eric-zaharia](https://github.com/eric-zaharia/)
4
+ - [ac68c1a79c](https://github.com/algolia/api-clients-automation/commit/ac68c1a79c) fix(specs): add facetFilters back to recommend fallbackParameters ([#6727](https://github.com/algolia/api-clients-automation/pull/6727)) by [@raed667](https://github.com/raed667/)
5
+
1
6
  ## [3.42.2](https://github.com/algolia/algoliasearch-client-ruby/compare/3.42.1...3.42.2)
2
7
 
3
8
  - [035c03ecad](https://github.com/algolia/api-clients-automation/commit/035c03ecad) fix(specs): BREAKING CHANGE – remove recommend query params overridden by the API ([#6604](https://github.com/algolia/api-clients-automation/pull/6604)) by [@raed667](https://github.com/raed667/)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algolia (3.42.2)
4
+ algolia (3.42.3)
5
5
  base64 (>= 0.2.0, < 1)
6
6
  faraday (>= 1.0.1, < 3.0)
7
7
  faraday-net_http_persistent (>= 0.15, < 3)
@@ -3542,6 +3542,8 @@ module Algolia
3542
3542
  # in order to transform records before indexing them to Algolia.
3543
3543
  # `set_transformation_options` must have been called, or the client created via `SearchClient.with_transformation`.
3544
3544
  #
3545
+ # Warning: Calling this method with an empty `objects` array will delete all records currently in the given `index_name`.
3546
+ #
3545
3547
  # @param index_name [String] the `index_name` to replace objects in. (required)
3546
3548
  # @param objects [Array] the array of objects to store in the given Algolia `index_name`. (required)
3547
3549
  # @param batch_size [Integer] the size of each chunk of objects sent in a single push call. (optional, default: 1000)
@@ -3559,6 +3561,12 @@ module Algolia
3559
3561
  )
3560
3562
  assert_ingestion_transporter!
3561
3563
 
3564
+ if objects.empty?
3565
+ @api_client.logger.warn(
3566
+ "replace_all_objects_with_transformation was called with an empty list of objects, which will delete all records currently in the \"#{index_name}\" index."
3567
+ )
3568
+ end
3569
+
3562
3570
  opts = Algolia::ChunkedHelperOptions.resolve(
3563
3571
  chunked_options,
3564
3572
  default_max_retries: Algolia::ChunkedHelperOptions::DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
@@ -4049,6 +4057,8 @@ module Algolia
4049
4057
 
4050
4058
  # Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
4051
4059
  #
4060
+ # Warning: Calling this method with an empty `objects` array will delete all records currently in the given `index_name`.
4061
+ #
4052
4062
  # @param index_name [String] The `index_name` to replace `objects` in.
4053
4063
  # @param objects [Array] The array of `objects` to store in the given Algolia `index_name`.
4054
4064
  # @param batch_size [int] The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
@@ -4064,6 +4074,12 @@ module Algolia
4064
4074
  request_options = {},
4065
4075
  chunked_options = nil
4066
4076
  )
4077
+ if objects.empty?
4078
+ @api_client.logger.warn(
4079
+ "replace_all_objects was called with an empty list of objects, which will delete all records currently in the \"#{index_name}\" index."
4080
+ )
4081
+ end
4082
+
4067
4083
  opts = Algolia::ChunkedHelperOptions.resolve(
4068
4084
  chunked_options,
4069
4085
  default_max_retries: Algolia::ChunkedHelperOptions::DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
@@ -8,11 +8,15 @@ module Algolia
8
8
 
9
9
  attr_accessor :transporter
10
10
 
11
+ # The logger, shared with the requester when it provides one.
12
+ attr_reader :logger
13
+
11
14
  # Initializes the ApiClient
12
15
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
13
16
  def initialize(config = Configuration.default)
14
17
  @config = config
15
18
  @requester = config.requester || Http::HttpRequester.new("net_http_persistent", LoggerHelper.create)
19
+ @logger = (@requester.logger if @requester.respond_to?(:logger)) || LoggerHelper.create
16
20
  @transporter = Transport::Transport.new(config, @requester)
17
21
  end
18
22
 
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Recommend
10
+ # Filter the search by facet values, so that only records with the same facet values are retrieved. **Prefer using the `filters` parameter, which supports all filter types and combinations with boolean operators.** - `[filter1, filter2]` is interpreted as `filter1 AND filter2`. - `[[filter1, filter2], filter3]` is interpreted as `filter1 OR filter2 AND filter3`. - `facet:-value` is interpreted as `NOT facet:value`. While it's best to avoid attributes that start with a `-`, you can still filter them by escaping with a backslash: `facet:\\-value`.
11
+ module FacetFilters
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Array<FacetFilters>",
17
+ :"String"
18
+ ]
19
+ end
20
+
21
+ # Builds the object
22
+ # @param [Mixed] Data to be matched against the list of oneOf items
23
+ # @return [Object] Returns the model or the data itself
24
+ def build(data)
25
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
26
+ # Note:
27
+ # - We do not attempt to check whether exactly one item matches.
28
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
29
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
30
+ # - TODO: scalar values are de facto behaving as if they were nullable.
31
+ # - TODO: logging when debugging is set.
32
+ openapi_one_of.each do |klass|
33
+ begin
34
+ # "nullable: true"
35
+ next if klass == :AnyType
36
+ typed_data = find_and_cast_into_type(klass, data)
37
+ return typed_data if typed_data
38
+ # rescue all errors so we keep iterating even if the current item lookup raises
39
+ rescue
40
+ end
41
+ end
42
+
43
+ openapi_one_of.include?(:AnyType) ? data : nil
44
+ end
45
+
46
+ private
47
+
48
+ SchemaMismatchError = Class.new(StandardError)
49
+
50
+ def find_and_cast_into_type(klass, data)
51
+ return if data.nil?
52
+
53
+ case klass.to_s
54
+ when "Boolean"
55
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
56
+ when "Float"
57
+ return data if data.instance_of?(Float)
58
+ when "Integer"
59
+ return data if data.instance_of?(Integer)
60
+ when "Time"
61
+ return Time.parse(data)
62
+ when "Date"
63
+ return Date.parse(data)
64
+ when "String"
65
+ return data if data.instance_of?(String)
66
+ # "type: object"
67
+ when "Object"
68
+ return data if data.instance_of?(Hash)
69
+ # "type: array"
70
+ when /\AArray<(?<sub_type>.+)>\z/
71
+ if data.instance_of?(Array)
72
+ sub_type = Regexp.last_match[:sub_type]
73
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
74
+ end
75
+ # "type: object" with "additionalProperties: { ... }"
76
+ when /\AHash<String, (?<sub_type>.+)>\z/
77
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
80
+ end
81
+ # model
82
+ else
83
+ const = Algolia::Recommend.const_get(klass)
84
+ if const
85
+ if const.respond_to?(:openapi_one_of)
86
+ # nested oneOf model
87
+ model = const.build(data)
88
+ elsif const.respond_to?(:discriminator_attributes)
89
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
90
+ model = const.build_from_hash(data)
91
+ end
92
+ else
93
+ # maybe it's an enum, or doens't have discriminators
94
+ model = const.build_from_hash(data)
95
+ end
96
+
97
+ return model if model
98
+ end
99
+ end
100
+
101
+ # if no match by now, raise
102
+ raise
103
+ rescue
104
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -242,6 +242,8 @@ module Algolia
242
242
 
243
243
  attr_accessor :re_ranking_apply_filter
244
244
 
245
+ attr_accessor :facet_filters
246
+
245
247
  # Attribute mapping from ruby-style variable name to JSON key.
246
248
  def self.attribute_map
247
249
  {
@@ -327,7 +329,8 @@ module Algolia
327
329
  :attribute_criteria_computed_by_min_proximity => :attributeCriteriaComputedByMinProximity,
328
330
  :rendering_content => :renderingContent,
329
331
  :enable_re_ranking => :enableReRanking,
330
- :re_ranking_apply_filter => :reRankingApplyFilter
332
+ :re_ranking_apply_filter => :reRankingApplyFilter,
333
+ :facet_filters => :facetFilters
331
334
  }
332
335
  end
333
336
 
@@ -416,7 +419,8 @@ module Algolia
416
419
  :attribute_criteria_computed_by_min_proximity => :"Boolean",
417
420
  :rendering_content => :"RenderingContent",
418
421
  :enable_re_ranking => :"Boolean",
419
- :re_ranking_apply_filter => :"ReRankingApplyFilter"
422
+ :re_ranking_apply_filter => :"ReRankingApplyFilter",
423
+ :facet_filters => :"FacetFilters"
420
424
  }
421
425
  end
422
426
 
@@ -849,6 +853,10 @@ module Algolia
849
853
  if attributes.key?(:re_ranking_apply_filter)
850
854
  self.re_ranking_apply_filter = attributes[:re_ranking_apply_filter]
851
855
  end
856
+
857
+ if attributes.key?(:facet_filters)
858
+ self.facet_filters = attributes[:facet_filters]
859
+ end
852
860
  end
853
861
 
854
862
  # Checks equality by comparing each attribute.
@@ -938,7 +946,8 @@ module Algolia
938
946
  attribute_criteria_computed_by_min_proximity == other.attribute_criteria_computed_by_min_proximity &&
939
947
  rendering_content == other.rendering_content &&
940
948
  enable_re_ranking == other.enable_re_ranking &&
941
- re_ranking_apply_filter == other.re_ranking_apply_filter
949
+ re_ranking_apply_filter == other.re_ranking_apply_filter &&
950
+ facet_filters == other.facet_filters
942
951
  end
943
952
 
944
953
  # @see the `==` method
@@ -1033,7 +1042,8 @@ module Algolia
1033
1042
  attribute_criteria_computed_by_min_proximity,
1034
1043
  rendering_content,
1035
1044
  enable_re_ranking,
1036
- re_ranking_apply_filter
1045
+ re_ranking_apply_filter,
1046
+ facet_filters
1037
1047
  ].hash
1038
1048
  end
1039
1049
 
@@ -3,5 +3,5 @@
3
3
  # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
4
 
5
5
  module Algolia
6
- VERSION = "3.42.2"
6
+ VERSION = "3.42.3"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algolia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.42.2
4
+ version: 3.42.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://alg.li/support
@@ -734,6 +734,7 @@ files:
734
734
  - lib/algolia/models/recommend/error_base.rb
735
735
  - lib/algolia/models/recommend/exact_on_single_word_query.rb
736
736
  - lib/algolia/models/recommend/exhaustive.rb
737
+ - lib/algolia/models/recommend/facet_filters.rb
737
738
  - lib/algolia/models/recommend/facet_ordering.rb
738
739
  - lib/algolia/models/recommend/facet_stats.rb
739
740
  - lib/algolia/models/recommend/fallback_params.rb