algolia 3.25.0 → 3.26.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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +15 -4
  8. data/lib/algolia/api/search_client.rb +4 -2
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  31. data/lib/algolia/models/composition/external_source.rb +211 -0
  32. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  33. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  34. data/lib/algolia/models/composition/injected_item.rb +253 -0
  35. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  36. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  37. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  38. data/lib/algolia/models/composition/injection.rb +222 -0
  39. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  40. data/lib/algolia/models/composition/main.rb +207 -0
  41. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  42. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  43. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  44. data/lib/algolia/models/composition/optional_words.rb +110 -0
  45. data/lib/algolia/models/composition/query_type.rb +35 -0
  46. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  47. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  48. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  49. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  50. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  51. data/lib/algolia/models/composition/search.rb +217 -0
  52. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  53. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  54. data/lib/algolia/models/composition/search_source.rb +211 -0
  55. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  56. data/lib/algolia/models/composition/task_status.rb +34 -0
  57. data/lib/algolia/models/composition/time_range.rb +219 -0
  58. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  59. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  60. data/lib/algolia/version.rb +1 -1
  61. metadata +52 -1
@@ -0,0 +1,222 @@
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 Composition
10
+ # Adds the provided metadata to each injected hit via an `_extra` attribute.
11
+ class InjectedItemHitsMetadata
12
+ # When true, the `_injectedItemKey` field is set in the `_extra` object of each affected hit.
13
+ attr_accessor :add_item_key
14
+
15
+ # The user-defined key-value pairs that will be placed in the `_extra` field of each affected hit.
16
+ attr_accessor :extra
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :add_item_key => :addItemKey,
22
+ :extra => :extra
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.types_mapping
28
+ {
29
+ :add_item_key => :"Boolean",
30
+ :extra => :"Hash<String, Object>"
31
+ }
32
+ end
33
+
34
+ # List of attributes with nullable: true
35
+ def self.openapi_nullable
36
+ Set.new(
37
+ []
38
+ )
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ raise(
46
+ ArgumentError,
47
+ "The input argument (attributes) must be a hash in `Algolia::InjectedItemHitsMetadata` initialize method"
48
+ )
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ raise(
55
+ ArgumentError,
56
+ "`#{k}` is not a valid attribute in `Algolia::InjectedItemHitsMetadata`. Please check the name to make sure it's valid. List of attributes: " +
57
+ self.class.attribute_map.keys.inspect
58
+ )
59
+ end
60
+
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:add_item_key)
65
+ self.add_item_key = attributes[:add_item_key]
66
+ end
67
+
68
+ if attributes.key?(:extra)
69
+ if (value = attributes[:extra]).is_a?(Hash)
70
+ self.extra = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(other)
78
+ return true if self.equal?(other)
79
+ self.class == other.class &&
80
+ add_item_key == other.add_item_key &&
81
+ extra == other.extra
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(other)
87
+ self == other
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Integer] Hash code
92
+ def hash
93
+ [add_item_key, extra].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def self.build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ attributes = attributes.transform_keys(&:to_sym)
102
+ transformed_hash = {}
103
+ types_mapping.each_pair do |key, type|
104
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
105
+ transformed_hash[key.to_sym] = nil
106
+ elsif type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[attribute_map[key]].is_a?(Array)
110
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
111
+ _deserialize(::Regexp.last_match(1), v)
112
+ }
113
+ end
114
+ elsif !attributes[attribute_map[key]].nil?
115
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
116
+ end
117
+ end
118
+
119
+ new(transformed_hash)
120
+ end
121
+
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
126
+ def self._deserialize(type, value)
127
+ case type.to_sym
128
+ when :Time
129
+ Time.parse(value)
130
+ when :Date
131
+ Date.parse(value)
132
+ when :String
133
+ value.to_s
134
+ when :Integer
135
+ value.to_i
136
+ when :Float
137
+ value.to_f
138
+ when :Boolean
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
140
+ true
141
+ else
142
+ false
143
+ end
144
+
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ # model
160
+ else
161
+ # models (e.g. Pet) or oneOf
162
+ klass = Algolia::Composition.const_get(type)
163
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
164
+ .build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ def to_json(*_args)
181
+ to_hash.to_json
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to?(:to_hash)
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
222
+ end
@@ -0,0 +1,209 @@
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 Composition
10
+ # Used to add metadata to the results of the injectedItem.
11
+ class InjectedItemMetadata
12
+ attr_accessor :hits
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :hits => :hits
18
+ }
19
+ end
20
+
21
+ # Attribute type mapping.
22
+ def self.types_mapping
23
+ {
24
+ :hits => :"InjectedItemHitsMetadata"
25
+ }
26
+ end
27
+
28
+ # List of attributes with nullable: true
29
+ def self.openapi_nullable
30
+ Set.new(
31
+ []
32
+ )
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ raise(
40
+ ArgumentError,
41
+ "The input argument (attributes) must be a hash in `Algolia::InjectedItemMetadata` initialize method"
42
+ )
43
+ end
44
+
45
+ # check to see if the attribute exists and convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h|
47
+ if (!self.class.attribute_map.key?(k.to_sym))
48
+ raise(
49
+ ArgumentError,
50
+ "`#{k}` is not a valid attribute in `Algolia::InjectedItemMetadata`. Please check the name to make sure it's valid. List of attributes: " +
51
+ self.class.attribute_map.keys.inspect
52
+ )
53
+ end
54
+
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:hits)
59
+ self.hits = attributes[:hits]
60
+ end
61
+ end
62
+
63
+ # Checks equality by comparing each attribute.
64
+ # @param [Object] Object to be compared
65
+ def ==(other)
66
+ return true if self.equal?(other)
67
+ self.class == other.class &&
68
+ hits == other.hits
69
+ end
70
+
71
+ # @see the `==` method
72
+ # @param [Object] Object to be compared
73
+ def eql?(other)
74
+ self == other
75
+ end
76
+
77
+ # Calculates hash code according to all attributes.
78
+ # @return [Integer] Hash code
79
+ def hash
80
+ [hits].hash
81
+ end
82
+
83
+ # Builds the object from hash
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ # @return [Object] Returns the model itself
86
+ def self.build_from_hash(attributes)
87
+ return nil unless attributes.is_a?(Hash)
88
+ attributes = attributes.transform_keys(&:to_sym)
89
+ transformed_hash = {}
90
+ types_mapping.each_pair do |key, type|
91
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
92
+ transformed_hash[key.to_sym] = nil
93
+ elsif type =~ /\AArray<(.*)>/i
94
+ # check to ensure the input is an array given that the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[attribute_map[key]].is_a?(Array)
97
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
98
+ _deserialize(::Regexp.last_match(1), v)
99
+ }
100
+ end
101
+ elsif !attributes[attribute_map[key]].nil?
102
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
103
+ end
104
+ end
105
+
106
+ new(transformed_hash)
107
+ end
108
+
109
+ # Deserializes the data based on type
110
+ # @param string type Data type
111
+ # @param string value Value to be deserialized
112
+ # @return [Object] Deserialized data
113
+ def self._deserialize(type, value)
114
+ case type.to_sym
115
+ when :Time
116
+ Time.parse(value)
117
+ when :Date
118
+ Date.parse(value)
119
+ when :String
120
+ value.to_s
121
+ when :Integer
122
+ value.to_i
123
+ when :Float
124
+ value.to_f
125
+ when :Boolean
126
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
127
+ true
128
+ else
129
+ false
130
+ end
131
+
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
135
+ when /\AArray<(?<inner_type>.+)>\z/
136
+ inner_type = Regexp.last_match[:inner_type]
137
+ value.map { |v| _deserialize(inner_type, v) }
138
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
139
+ k_type = Regexp.last_match[:k_type]
140
+ v_type = Regexp.last_match[:v_type]
141
+ {}.tap do |hash|
142
+ value.each do |k, v|
143
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
+ end
145
+ end
146
+ # model
147
+ else
148
+ # models (e.g. Pet) or oneOf
149
+ klass = Algolia::Composition.const_get(type)
150
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
151
+ .build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ def to_json(*_args)
168
+ to_hash.to_json
169
+ end
170
+
171
+ # Returns the object in the form of hash
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_hash
174
+ hash = {}
175
+ self.class.attribute_map.each_pair do |attr, param|
176
+ value = send(attr)
177
+ if value.nil?
178
+ is_nullable = self.class.openapi_nullable.include?(attr)
179
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
180
+ end
181
+
182
+ hash[param] = _to_hash(value)
183
+ end
184
+
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map { |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to?(:to_hash)
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+
206
+ end
207
+
208
+ end
209
+ end
@@ -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 Composition
10
+ module InjectedItemSource
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"ExternalSource",
16
+ :"SearchSource"
17
+ ]
18
+ end
19
+
20
+ # Builds the object
21
+ # @param [Mixed] Data to be matched against the list of oneOf items
22
+ # @return [Object] Returns the model or the data itself
23
+ def build(data)
24
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
25
+ # Note:
26
+ # - We do not attempt to check whether exactly one item matches.
27
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
28
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
29
+ # - TODO: scalar values are de facto behaving as if they were nullable.
30
+ # - TODO: logging when debugging is set.
31
+ openapi_one_of.each do |klass|
32
+ begin
33
+ # "nullable: true"
34
+ next if klass == :AnyType
35
+ typed_data = find_and_cast_into_type(klass, data)
36
+ return typed_data if typed_data
37
+ # rescue all errors so we keep iterating even if the current item lookup raises
38
+ rescue
39
+ end
40
+ end
41
+
42
+ openapi_one_of.include?(:AnyType) ? data : nil
43
+ end
44
+
45
+ private
46
+
47
+ SchemaMismatchError = Class.new(StandardError)
48
+
49
+ def find_and_cast_into_type(klass, data)
50
+ return if data.nil?
51
+
52
+ case klass.to_s
53
+ when "Boolean"
54
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
55
+ when "Float"
56
+ return data if data.instance_of?(Float)
57
+ when "Integer"
58
+ return data if data.instance_of?(Integer)
59
+ when "Time"
60
+ return Time.parse(data)
61
+ when "Date"
62
+ return Date.parse(data)
63
+ when "String"
64
+ return data if data.instance_of?(String)
65
+ # "type: object"
66
+ when "Object"
67
+ return data if data.instance_of?(Hash)
68
+ # "type: array"
69
+ when /\AArray<(?<sub_type>.+)>\z/
70
+ if data.instance_of?(Array)
71
+ sub_type = Regexp.last_match[:sub_type]
72
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
73
+ end
74
+ # "type: object" with "additionalProperties: { ... }"
75
+ when /\AHash<String, (?<sub_type>.+)>\z/
76
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
79
+ end
80
+ # model
81
+ else
82
+ const = Algolia::Composition.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:openapi_one_of)
85
+ # nested oneOf model
86
+ model = const.build(data)
87
+ elsif const.respond_to?(:discriminator_attributes)
88
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
89
+ model = const.build_from_hash(data)
90
+ end
91
+ else
92
+ # maybe it's an enum, or doens't have discriminators
93
+ model = const.build_from_hash(data)
94
+ end
95
+
96
+ return model if model
97
+ end
98
+ end
99
+
100
+ # if no match by now, raise
101
+ raise
102
+ rescue
103
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
104
+ end
105
+ end
106
+ end
107
+
108
+ end
109
+ end