exa-ai 0.12.2 → 0.14.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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -83
  3. data/exe/exa-ai +45 -152
  4. data/exe/exa-ai-agent-run-create +55 -20
  5. data/exe/exa-ai-agent-run-delete +1 -8
  6. data/exe/exa-ai-agent-run-events +21 -1
  7. data/exe/exa-ai-agent-run-list +1 -1
  8. data/exe/{exa-ai-research-list → exa-ai-agent-run-stop} +31 -32
  9. data/exe/exa-ai-answer +25 -0
  10. data/exe/exa-ai-context +6 -2
  11. data/exe/exa-ai-find-similar +26 -68
  12. data/exe/exa-ai-get-contents +138 -42
  13. data/exe/exa-ai-search +27 -104
  14. data/exe/exa-ai-search-monitor-batch +93 -0
  15. data/exe/exa-ai-search-monitor-create +104 -0
  16. data/exe/exa-ai-search-monitor-delete +69 -0
  17. data/exe/exa-ai-search-monitor-get +69 -0
  18. data/exe/exa-ai-search-monitor-list +73 -0
  19. data/exe/exa-ai-search-monitor-runs-get +68 -0
  20. data/exe/exa-ai-search-monitor-runs-list +75 -0
  21. data/exe/exa-ai-search-monitor-trigger +69 -0
  22. data/exe/exa-ai-search-monitor-update +102 -0
  23. data/lib/exa/cli/base.rb +57 -0
  24. data/lib/exa/cli/contents_flags.rb +199 -0
  25. data/lib/exa/cli/formatters/agent_run_formatter.rb +79 -3
  26. data/lib/exa/cli/formatters/search_formatter.rb +18 -2
  27. data/lib/exa/cli/formatters/search_monitor_formatter.rb +98 -0
  28. data/lib/exa/cli/search_parser.rb +46 -87
  29. data/lib/exa/client.rb +183 -333
  30. data/lib/exa/middleware/raise_error.rb +14 -0
  31. data/lib/exa/resources/agent_run.rb +5 -3
  32. data/lib/exa/resources/agent_run_deletion.rb +17 -0
  33. data/lib/exa/resources/answer.rb +3 -3
  34. data/lib/exa/resources/contents_result.rb +5 -1
  35. data/lib/exa/resources/find_similar_result.rb +5 -1
  36. data/lib/exa/resources/search_monitor.rb +42 -0
  37. data/lib/exa/resources/search_monitor_batch_result.rb +11 -0
  38. data/lib/exa/resources/{research_list.rb → search_monitor_list.rb} +3 -2
  39. data/lib/exa/resources/search_monitor_run.rb +46 -0
  40. data/lib/exa/resources/search_monitor_trigger_result.rb +11 -0
  41. data/lib/exa/resources/search_result.rb +11 -1
  42. data/lib/exa/services/agent_run_cancel.rb +1 -12
  43. data/lib/exa/services/agent_run_create.rb +1 -12
  44. data/lib/exa/services/agent_run_delete.rb +6 -14
  45. data/lib/exa/services/agent_run_events.rb +33 -4
  46. data/lib/exa/services/agent_run_get.rb +1 -12
  47. data/lib/exa/services/agent_run_list.rb +1 -12
  48. data/lib/exa/services/agent_run_stop.rb +21 -0
  49. data/lib/exa/services/agent_run_stream.rb +56 -52
  50. data/lib/exa/services/answer.rb +5 -2
  51. data/lib/exa/services/answer_stream.rb +57 -46
  52. data/lib/exa/services/context.rb +3 -1
  53. data/lib/exa/services/find_similar.rb +9 -2
  54. data/lib/exa/services/get_contents.rb +14 -15
  55. data/lib/exa/services/parameter_converter.rb +128 -111
  56. data/lib/exa/services/search.rb +58 -19
  57. data/lib/exa/services/search_monitors/batch.rb +36 -0
  58. data/lib/exa/services/search_monitors/create.rb +37 -0
  59. data/lib/exa/services/search_monitors/delete.rb +22 -0
  60. data/lib/exa/services/search_monitors/get.rb +22 -0
  61. data/lib/exa/services/search_monitors/list.rb +29 -0
  62. data/lib/exa/services/search_monitors/runs_get.rb +23 -0
  63. data/lib/exa/services/search_monitors/runs_list.rb +29 -0
  64. data/lib/exa/services/search_monitors/trigger.rb +22 -0
  65. data/lib/exa/services/search_monitors/update.rb +42 -0
  66. data/lib/exa/services/search_stream.rb +38 -0
  67. data/lib/exa/version.rb +1 -1
  68. data/lib/exa.rb +18 -56
  69. metadata +31 -94
  70. data/exe/exa-ai-enrichment-cancel +0 -108
  71. data/exe/exa-ai-enrichment-create +0 -226
  72. data/exe/exa-ai-enrichment-delete +0 -122
  73. data/exe/exa-ai-enrichment-get +0 -104
  74. data/exe/exa-ai-enrichment-list +0 -99
  75. data/exe/exa-ai-enrichment-update +0 -171
  76. data/exe/exa-ai-import-create +0 -253
  77. data/exe/exa-ai-import-delete +0 -92
  78. data/exe/exa-ai-import-get +0 -92
  79. data/exe/exa-ai-import-list +0 -72
  80. data/exe/exa-ai-import-update +0 -164
  81. data/exe/exa-ai-monitor-create +0 -223
  82. data/exe/exa-ai-monitor-delete +0 -101
  83. data/exe/exa-ai-monitor-get +0 -92
  84. data/exe/exa-ai-monitor-list +0 -90
  85. data/exe/exa-ai-monitor-runs-get +0 -103
  86. data/exe/exa-ai-monitor-runs-list +0 -110
  87. data/exe/exa-ai-monitor-update +0 -207
  88. data/exe/exa-ai-research-get +0 -109
  89. data/exe/exa-ai-research-start +0 -174
  90. data/exe/exa-ai-webset-cancel +0 -97
  91. data/exe/exa-ai-webset-create +0 -254
  92. data/exe/exa-ai-webset-delete +0 -111
  93. data/exe/exa-ai-webset-get +0 -93
  94. data/exe/exa-ai-webset-item-delete +0 -111
  95. data/exe/exa-ai-webset-item-get +0 -105
  96. data/exe/exa-ai-webset-item-list +0 -108
  97. data/exe/exa-ai-webset-list +0 -91
  98. data/exe/exa-ai-webset-search-cancel +0 -104
  99. data/exe/exa-ai-webset-search-create +0 -247
  100. data/exe/exa-ai-webset-search-get +0 -105
  101. data/exe/exa-ai-webset-update +0 -143
  102. data/lib/exa/cli/formatters/enrichment_formatter.rb +0 -125
  103. data/lib/exa/cli/formatters/import_formatter.rb +0 -153
  104. data/lib/exa/cli/formatters/monitor_formatter.rb +0 -144
  105. data/lib/exa/cli/formatters/monitor_run_formatter.rb +0 -126
  106. data/lib/exa/cli/formatters/research_formatter.rb +0 -124
  107. data/lib/exa/cli/formatters/webset_formatter.rb +0 -134
  108. data/lib/exa/cli/formatters/webset_item_formatter.rb +0 -131
  109. data/lib/exa/cli/formatters/webset_search_formatter.rb +0 -57
  110. data/lib/exa/constants/websets.rb +0 -19
  111. data/lib/exa/resources/import.rb +0 -86
  112. data/lib/exa/resources/import_collection.rb +0 -33
  113. data/lib/exa/resources/monitor.rb +0 -48
  114. data/lib/exa/resources/monitor_collection.rb +0 -30
  115. data/lib/exa/resources/monitor_run.rb +0 -52
  116. data/lib/exa/resources/monitor_run_collection.rb +0 -30
  117. data/lib/exa/resources/research_task.rb +0 -39
  118. data/lib/exa/resources/webset.rb +0 -74
  119. data/lib/exa/resources/webset_collection.rb +0 -33
  120. data/lib/exa/resources/webset_enrichment.rb +0 -71
  121. data/lib/exa/resources/webset_enrichment_collection.rb +0 -28
  122. data/lib/exa/resources/webset_item_collection.rb +0 -33
  123. data/lib/exa/resources/webset_search.rb +0 -112
  124. data/lib/exa/services/research_get.rb +0 -30
  125. data/lib/exa/services/research_list.rb +0 -37
  126. data/lib/exa/services/research_start.rb +0 -26
  127. data/lib/exa/services/websets/cancel.rb +0 -36
  128. data/lib/exa/services/websets/cancel_enrichment.rb +0 -35
  129. data/lib/exa/services/websets/cancel_search.rb +0 -44
  130. data/lib/exa/services/websets/create.rb +0 -45
  131. data/lib/exa/services/websets/create_enrichment.rb +0 -35
  132. data/lib/exa/services/websets/create_search.rb +0 -48
  133. data/lib/exa/services/websets/create_search_validator.rb +0 -128
  134. data/lib/exa/services/websets/create_validator.rb +0 -213
  135. data/lib/exa/services/websets/delete.rb +0 -36
  136. data/lib/exa/services/websets/delete_enrichment.rb +0 -35
  137. data/lib/exa/services/websets/delete_item.rb +0 -20
  138. data/lib/exa/services/websets/get_item.rb +0 -20
  139. data/lib/exa/services/websets/get_search.rb +0 -43
  140. data/lib/exa/services/websets/import_create.rb +0 -40
  141. data/lib/exa/services/websets/import_delete.rb +0 -37
  142. data/lib/exa/services/websets/import_get.rb +0 -37
  143. data/lib/exa/services/websets/import_list.rb +0 -25
  144. data/lib/exa/services/websets/import_update.rb +0 -38
  145. data/lib/exa/services/websets/import_upload.rb +0 -58
  146. data/lib/exa/services/websets/list.rb +0 -25
  147. data/lib/exa/services/websets/list_items.rb +0 -26
  148. data/lib/exa/services/websets/monitors/create.rb +0 -42
  149. data/lib/exa/services/websets/monitors/delete.rb +0 -32
  150. data/lib/exa/services/websets/monitors/get.rb +0 -33
  151. data/lib/exa/services/websets/monitors/list.rb +0 -27
  152. data/lib/exa/services/websets/monitors/runs/get.rb +0 -37
  153. data/lib/exa/services/websets/monitors/runs/list.rb +0 -30
  154. data/lib/exa/services/websets/monitors/update.rb +0 -33
  155. data/lib/exa/services/websets/retrieve.rb +0 -47
  156. data/lib/exa/services/websets/retrieve_enrichment.rb +0 -35
  157. data/lib/exa/services/websets/update.rb +0 -37
  158. data/lib/exa/services/websets/update_enrichment.rb +0 -36
  159. data/lib/exa/services/websets_parameter_converter.rb +0 -45
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- # Validates parameters for webset search creation
7
- class CreateSearchValidator
8
- VALID_ENTITY_TYPES = %w[company person article research_paper custom].freeze
9
- VALID_BEHAVIORS = %w[override append].freeze
10
- VALID_SOURCE_TYPES = %w[import webset].freeze
11
-
12
- class << self
13
- def validate!(params)
14
- validate_query!(params[:query]) if params[:query]
15
- validate_count!(params[:count]) if params[:count]
16
- validate_entity!(params[:entity]) if params[:entity]
17
- validate_criteria!(params[:criteria]) if params[:criteria]
18
- validate_scope!(params[:scope]) if params[:scope]
19
- validate_exclude!(params[:exclude]) if params[:exclude]
20
- validate_behavior!(params[:behavior]) if params[:behavior]
21
- validate_metadata!(params[:metadata]) if params[:metadata]
22
- end
23
-
24
- private
25
-
26
- def validate_query!(query)
27
- raise ArgumentError, "query must be a String" unless query.is_a?(String)
28
- raise ArgumentError, "query cannot be empty" if query.strip.empty?
29
- raise ArgumentError, "query cannot exceed 5000 characters" if query.length > 5000
30
- end
31
-
32
- def validate_count!(count)
33
- raise ArgumentError, "count must be a positive Integer" unless count.is_a?(Integer) && count > 0
34
- end
35
-
36
- def validate_entity!(entity)
37
- raise ArgumentError, "entity must be a Hash" unless entity.is_a?(Hash)
38
- raise ArgumentError, "entity[:type] is required" unless entity[:type]
39
-
40
- type = entity[:type]
41
- unless VALID_ENTITY_TYPES.include?(type)
42
- raise ArgumentError, "entity[:type] must be one of: #{VALID_ENTITY_TYPES.join(', ')}"
43
- end
44
-
45
- if type == "custom"
46
- raise ArgumentError, "entity[:description] is required for custom entity type" unless entity[:description]
47
- validate_string_length!(entity[:description], "entity[:description]", min: 2, max: 200)
48
- end
49
- end
50
-
51
- def validate_criteria!(criteria)
52
- raise ArgumentError, "criteria must be an Array" unless criteria.is_a?(Array)
53
- raise ArgumentError, "criteria must have at least 1 item" if criteria.empty?
54
- raise ArgumentError, "criteria cannot have more than 5 items" if criteria.length > 5
55
-
56
- criteria.each_with_index do |criterion, index|
57
- raise ArgumentError, "criteria[#{index}] must be a Hash" unless criterion.is_a?(Hash)
58
- raise ArgumentError, "criteria[#{index}][:description] is required" unless criterion[:description]
59
- validate_string_length!(criterion[:description], "criteria[#{index}][:description]", min: 1, max: 1000)
60
- end
61
- end
62
-
63
- def validate_scope!(scope)
64
- raise ArgumentError, "scope must be an Array" unless scope.is_a?(Array)
65
-
66
- scope.each_with_index do |item, index|
67
- validate_source_reference!(item, "scope[#{index}]")
68
-
69
- next unless item[:relationship]
70
-
71
- rel = item[:relationship]
72
- raise ArgumentError, "scope[#{index}][:relationship] must be a Hash" unless rel.is_a?(Hash)
73
- raise ArgumentError, "scope[#{index}][:relationship][:definition] is required" unless rel[:definition]
74
- raise ArgumentError, "scope[#{index}][:relationship][:limit] is required" unless rel[:limit]
75
-
76
- limit = rel[:limit]
77
- unless limit.is_a?(Integer) && limit >= 1 && limit <= 10
78
- raise ArgumentError, "scope[#{index}][:relationship][:limit] must be an Integer between 1 and 10"
79
- end
80
- end
81
- end
82
-
83
- def validate_exclude!(exclude)
84
- raise ArgumentError, "exclude must be an Array" unless exclude.is_a?(Array)
85
-
86
- exclude.each_with_index do |item, index|
87
- validate_source_reference!(item, "exclude[#{index}]")
88
- end
89
- end
90
-
91
- def validate_behavior!(behavior)
92
- unless VALID_BEHAVIORS.include?(behavior)
93
- raise ArgumentError, "behavior must be one of: #{VALID_BEHAVIORS.join(', ')}"
94
- end
95
- end
96
-
97
- def validate_metadata!(metadata)
98
- raise ArgumentError, "metadata must be a Hash" unless metadata.is_a?(Hash)
99
-
100
- metadata.each do |key, value|
101
- raise ArgumentError, "metadata values must be Strings" unless value.is_a?(String)
102
- raise ArgumentError, "metadata value for '#{key}' cannot exceed 1000 characters" if value.length > 1000
103
- end
104
- end
105
-
106
- def validate_source_reference!(item, context)
107
- raise ArgumentError, "#{context} must be a Hash" unless item.is_a?(Hash)
108
- raise ArgumentError, "#{context}[:source] is required" unless item[:source]
109
- raise ArgumentError, "#{context}[:id] is required" unless item[:id]
110
-
111
- source = item[:source]
112
- unless VALID_SOURCE_TYPES.include?(source)
113
- raise ArgumentError, "#{context}[:source] must be one of: #{VALID_SOURCE_TYPES.join(', ')}"
114
- end
115
-
116
- raise ArgumentError, "#{context}[:id] must be a non-empty String" unless item[:id].is_a?(String) && !item[:id].empty?
117
- end
118
-
119
- def validate_string_length!(value, name, min: nil, max: nil)
120
- raise ArgumentError, "#{name} must be a String" unless value.is_a?(String)
121
- raise ArgumentError, "#{name} must be at least #{min} characters" if min && value.length < min
122
- raise ArgumentError, "#{name} cannot exceed #{max} characters" if max && value.length > max
123
- end
124
- end
125
- end
126
- end
127
- end
128
- end
@@ -1,213 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../../constants/websets"
4
-
5
- module Exa
6
- module Services
7
- module Websets
8
- # Validates parameters for webset creation
9
- class CreateValidator
10
- VALID_ENTITY_TYPES = Constants::Websets::ENTITY_TYPES
11
- VALID_ENRICHMENT_FORMATS = Constants::Websets::ENRICHMENT_FORMATS
12
- VALID_SOURCE_TYPES = Constants::Websets::SOURCE_TYPES
13
-
14
- class << self
15
- def validate!(params)
16
- validate_has_search_or_import!(params)
17
- validate_search!(params[:search]) if params[:search]
18
- validate_import!(params[:import]) if params[:import]
19
- validate_enrichments!(params[:enrichments]) if params[:enrichments]
20
- validate_exclude!(params[:exclude]) if params[:exclude]
21
- validate_external_id!(params[:externalId]) if params[:externalId]
22
- validate_title!(params[:title]) if params[:title]
23
- validate_metadata!(params[:metadata]) if params[:metadata]
24
- validate_no_duplicate_ids_in_import_and_scope!(params)
25
- end
26
-
27
- private
28
-
29
- def validate_has_search_or_import!(params)
30
- return if params[:search] || params[:import]
31
-
32
- raise ArgumentError, "At least one of :search or :import is required"
33
- end
34
-
35
- def validate_search!(search)
36
- raise ArgumentError, "search must be a Hash" unless search.is_a?(Hash)
37
- raise ArgumentError, "search[:query] is required" unless search[:query]
38
- raise ArgumentError, "search[:query] must be a String" unless search[:query].is_a?(String)
39
- raise ArgumentError, "search[:query] cannot be empty" if search[:query].strip.empty?
40
- raise ArgumentError, "search[:query] cannot exceed 5000 characters" if search[:query].length > 5000
41
-
42
- validate_count!(search[:count]) if search[:count]
43
- validate_entity!(search[:entity]) if search[:entity]
44
- validate_criteria!(search[:criteria]) if search[:criteria]
45
- validate_scope!(search[:scope]) if search[:scope]
46
- validate_exclude_list!(search[:exclude]) if search[:exclude]
47
- end
48
-
49
- def validate_count!(count)
50
- raise ArgumentError, "count must be a positive Integer" unless count.is_a?(Integer) && count > 0
51
- end
52
-
53
- def validate_entity!(entity)
54
- raise ArgumentError, "entity must be a Hash" unless entity.is_a?(Hash)
55
- raise ArgumentError, "entity[:type] is required" unless entity[:type]
56
-
57
- type = entity[:type]
58
- unless VALID_ENTITY_TYPES.include?(type)
59
- raise ArgumentError, "entity[:type] must be one of: #{VALID_ENTITY_TYPES.join(', ')}"
60
- end
61
-
62
- if type == "custom"
63
- raise ArgumentError, "entity[:description] is required for custom entity type" unless entity[:description]
64
- validate_string_length!(entity[:description], "entity[:description]", min: 2, max: 200)
65
- end
66
- end
67
-
68
- def validate_criteria!(criteria)
69
- raise ArgumentError, "criteria must be an Array" unless criteria.is_a?(Array)
70
- raise ArgumentError, "criteria must have at least 1 item" if criteria.empty?
71
- raise ArgumentError, "criteria cannot have more than 5 items" if criteria.length > 5
72
-
73
- criteria.each_with_index do |criterion, index|
74
- raise ArgumentError, "criteria[#{index}] must be a Hash" unless criterion.is_a?(Hash)
75
- raise ArgumentError, "criteria[#{index}][:description] is required" unless criterion[:description]
76
- validate_string_length!(criterion[:description], "criteria[#{index}][:description]", min: 1, max: 1000)
77
- end
78
- end
79
-
80
- def validate_scope!(scope)
81
- raise ArgumentError, "scope must be an Array" unless scope.is_a?(Array)
82
-
83
- scope.each_with_index do |item, index|
84
- validate_source_reference!(item, "scope[#{index}]")
85
-
86
- next unless item[:relationship]
87
-
88
- rel = item[:relationship]
89
- raise ArgumentError, "scope[#{index}][:relationship] must be a Hash" unless rel.is_a?(Hash)
90
- raise ArgumentError, "scope[#{index}][:relationship][:definition] is required" unless rel[:definition]
91
- raise ArgumentError, "scope[#{index}][:relationship][:limit] is required" unless rel[:limit]
92
-
93
- limit = rel[:limit]
94
- unless limit.is_a?(Integer) && limit >= 1 && limit <= 10
95
- raise ArgumentError, "scope[#{index}][:relationship][:limit] must be an Integer between 1 and 10"
96
- end
97
- end
98
- end
99
-
100
- def validate_exclude_list!(exclude)
101
- raise ArgumentError, "exclude must be an Array" unless exclude.is_a?(Array)
102
-
103
- exclude.each_with_index do |item, index|
104
- validate_source_reference!(item, "exclude[#{index}]")
105
- end
106
- end
107
-
108
- def validate_import!(import)
109
- raise ArgumentError, "import must be an Array" unless import.is_a?(Array)
110
-
111
- import.each_with_index do |item, index|
112
- validate_source_reference!(item, "import[#{index}]")
113
- end
114
- end
115
-
116
- def validate_enrichments!(enrichments)
117
- raise ArgumentError, "enrichments must be an Array" unless enrichments.is_a?(Array)
118
-
119
- enrichments.each_with_index do |enrichment, index|
120
- raise ArgumentError, "enrichments[#{index}] must be a Hash" unless enrichment.is_a?(Hash)
121
- raise ArgumentError, "enrichments[#{index}][:description] is required" unless enrichment[:description]
122
- validate_string_length!(enrichment[:description], "enrichments[#{index}][:description]", min: 1, max: 5000)
123
-
124
- if enrichment[:format]
125
- format = enrichment[:format]
126
- unless VALID_ENRICHMENT_FORMATS.include?(format)
127
- raise ArgumentError, "enrichments[#{index}][:format] must be one of: #{VALID_ENRICHMENT_FORMATS.join(', ')}"
128
- end
129
-
130
- if format == "options"
131
- validate_enrichment_options!(enrichment[:options], index)
132
- end
133
- end
134
- end
135
- end
136
-
137
- def validate_enrichment_options!(options, enrichment_index)
138
- unless options.is_a?(Array)
139
- raise ArgumentError, "enrichments[#{enrichment_index}][:options] is required when format is 'options'"
140
- end
141
-
142
- if options.empty? || options.length > 150
143
- raise ArgumentError, "enrichments[#{enrichment_index}][:options] must have between 1 and 150 items"
144
- end
145
-
146
- options.each_with_index do |option, option_index|
147
- unless option.is_a?(Hash) && option[:label]
148
- raise ArgumentError, "enrichments[#{enrichment_index}][:options][#{option_index}][:label] is required"
149
- end
150
- end
151
- end
152
-
153
- def validate_exclude!(exclude)
154
- validate_exclude_list!(exclude)
155
- end
156
-
157
- def validate_external_id!(external_id)
158
- raise ArgumentError, "externalId must be a String" unless external_id.is_a?(String)
159
- raise ArgumentError, "externalId cannot exceed 300 characters" if external_id.length > 300
160
- end
161
-
162
- def validate_title!(title)
163
- raise ArgumentError, "title must be a String" unless title.is_a?(String)
164
- raise ArgumentError, "title cannot be empty" if title.strip.empty?
165
- raise ArgumentError, "title cannot exceed 1000 characters" if title.length > 1000
166
- end
167
-
168
- def validate_metadata!(metadata)
169
- raise ArgumentError, "metadata must be a Hash" unless metadata.is_a?(Hash)
170
-
171
- metadata.each do |key, value|
172
- raise ArgumentError, "metadata values must be Strings" unless value.is_a?(String)
173
- raise ArgumentError, "metadata value for '#{key}' cannot exceed 1000 characters" if value.length > 1000
174
- end
175
- end
176
-
177
- def validate_source_reference!(item, context)
178
- raise ArgumentError, "#{context} must be a Hash" unless item.is_a?(Hash)
179
- raise ArgumentError, "#{context}[:source] is required" unless item[:source]
180
- raise ArgumentError, "#{context}[:id] is required" unless item[:id]
181
-
182
- source = item[:source]
183
- unless VALID_SOURCE_TYPES.include?(source)
184
- raise ArgumentError, "#{context}[:source] must be one of: #{VALID_SOURCE_TYPES.join(', ')}"
185
- end
186
-
187
- raise ArgumentError, "#{context}[:id] must be a non-empty String" unless item[:id].is_a?(String) && !item[:id].empty?
188
- end
189
-
190
- def validate_string_length!(value, name, min: nil, max: nil)
191
- raise ArgumentError, "#{name} must be a String" unless value.is_a?(String)
192
- raise ArgumentError, "#{name} must be at least #{min} characters" if min && value.length < min
193
- raise ArgumentError, "#{name} cannot exceed #{max} characters" if max && value.length > max
194
- end
195
-
196
- def validate_no_duplicate_ids_in_import_and_scope!(params)
197
- return unless params[:import] && params[:search] && params[:search][:scope]
198
-
199
- import_ids = params[:import].map { |item| item[:id] }
200
- scope_ids = params[:search][:scope].map { |item| item[:id] }
201
-
202
- duplicates = import_ids & scope_ids
203
-
204
- return if duplicates.empty?
205
-
206
- raise ArgumentError,
207
- "Cannot use the same import/webset ID in both :import and search[:scope]: #{duplicates.join(', ')}"
208
- end
209
- end
210
- end
211
- end
212
- end
213
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class Delete
7
- def initialize(connection, id:)
8
- @connection = connection
9
- @id = id
10
- end
11
-
12
- def call
13
- response = @connection.delete("/websets/v0/websets/#{@id}")
14
- body = response.body
15
-
16
- Resources::Webset.new(
17
- id: body["id"],
18
- object: body["object"],
19
- status: body["status"],
20
- external_id: body["externalId"],
21
- title: body["title"],
22
- searches: body["searches"],
23
- imports: body["imports"],
24
- enrichments: body["enrichments"],
25
- monitors: body["monitors"],
26
- excludes: body["excludes"],
27
- metadata: body["metadata"],
28
- created_at: body["createdAt"],
29
- updated_at: body["updatedAt"],
30
- items: body["items"]
31
- )
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class DeleteEnrichment
7
- def initialize(connection, webset_id:, id:)
8
- @connection = connection
9
- @webset_id = webset_id
10
- @id = id
11
- end
12
-
13
- def call
14
- response = @connection.delete("/websets/v0/websets/#{@webset_id}/enrichments/#{@id}")
15
- body = response.body
16
-
17
- Resources::WebsetEnrichment.new(
18
- id: body["id"],
19
- object: body["object"],
20
- status: body["status"],
21
- webset_id: body["websetId"],
22
- title: body["title"],
23
- description: body["description"],
24
- format: body["format"],
25
- options: body["options"],
26
- instructions: body["instructions"],
27
- metadata: body["metadata"],
28
- created_at: body["createdAt"],
29
- updated_at: body["updatedAt"]
30
- )
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class DeleteItem
7
- def initialize(connection, webset_id:, id:)
8
- @connection = connection
9
- @webset_id = webset_id
10
- @id = id
11
- end
12
-
13
- def call
14
- @connection.delete("/websets/v0/websets/#{@webset_id}/items/#{@id}")
15
- true
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class GetItem
7
- def initialize(connection, webset_id:, id:)
8
- @connection = connection
9
- @webset_id = webset_id
10
- @id = id
11
- end
12
-
13
- def call
14
- response = @connection.get("/websets/v0/websets/#{@webset_id}/items/#{@id}")
15
- response.body
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class GetSearch
7
- def initialize(connection, webset_id:, id:)
8
- @connection = connection
9
- @webset_id = webset_id
10
- @id = id
11
- end
12
-
13
- def call
14
- response = @connection.get(
15
- "/websets/v0/websets/#{@webset_id}/searches/#{@id}"
16
- )
17
- body = response.body
18
-
19
- Resources::WebsetSearch.new(
20
- id: body["id"],
21
- object: body["object"],
22
- status: body["status"],
23
- webset_id: body["websetId"],
24
- query: body["query"],
25
- entity: body["entity"],
26
- criteria: body["criteria"],
27
- count: body["count"],
28
- behavior: body["behavior"],
29
- exclude: body["exclude"],
30
- scope: body["scope"],
31
- progress: body["progress"],
32
- recall: body["recall"],
33
- metadata: body["metadata"],
34
- canceled_at: body["canceledAt"],
35
- canceled_reason: body["canceledReason"],
36
- created_at: body["createdAt"],
37
- updated_at: body["updatedAt"]
38
- )
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class CreateImport
7
- def initialize(connection, **params)
8
- @connection = connection
9
- @params = params
10
- end
11
-
12
- def call
13
- response = @connection.post(
14
- "/websets/v0/imports",
15
- @params
16
- )
17
- body = response.body
18
-
19
- Resources::Import.new(
20
- id: body["id"],
21
- object: body["object"],
22
- status: body["status"],
23
- format: body["format"],
24
- entity: body["entity"],
25
- title: body["title"],
26
- count: body["count"],
27
- metadata: body["metadata"],
28
- failed_reason: body["failedReason"],
29
- failed_at: body["failedAt"],
30
- failed_message: body["failedMessage"],
31
- created_at: body["createdAt"],
32
- updated_at: body["updatedAt"],
33
- upload_url: body["uploadUrl"],
34
- upload_valid_until: body["uploadValidUntil"]
35
- )
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class DeleteImport
7
- def initialize(connection, id:)
8
- @connection = connection
9
- @id = id
10
- end
11
-
12
- def call
13
- response = @connection.delete("/websets/v0/imports/#{@id}")
14
- body = response.body
15
-
16
- Resources::Import.new(
17
- id: body["id"],
18
- object: body["object"],
19
- status: body["status"],
20
- format: body["format"],
21
- entity: body["entity"],
22
- title: body["title"],
23
- count: body["count"],
24
- metadata: body["metadata"],
25
- failed_reason: body["failedReason"],
26
- failed_at: body["failedAt"],
27
- failed_message: body["failedMessage"],
28
- created_at: body["createdAt"],
29
- updated_at: body["updatedAt"],
30
- upload_url: body["uploadUrl"],
31
- upload_valid_until: body["uploadValidUntil"]
32
- )
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class GetImport
7
- def initialize(connection, id:)
8
- @connection = connection
9
- @id = id
10
- end
11
-
12
- def call
13
- response = @connection.get("/websets/v0/imports/#{@id}")
14
- body = response.body
15
-
16
- Resources::Import.new(
17
- id: body["id"],
18
- object: body["object"],
19
- status: body["status"],
20
- format: body["format"],
21
- entity: body["entity"],
22
- title: body["title"],
23
- count: body["count"],
24
- metadata: body["metadata"],
25
- failed_reason: body["failedReason"],
26
- failed_at: body["failedAt"],
27
- failed_message: body["failedMessage"],
28
- created_at: body["createdAt"],
29
- updated_at: body["updatedAt"],
30
- upload_url: body["uploadUrl"],
31
- upload_valid_until: body["uploadValidUntil"]
32
- )
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class ListImports
7
- def initialize(connection, **params)
8
- @connection = connection
9
- @params = params
10
- end
11
-
12
- def call
13
- response = @connection.get("/websets/v0/imports", @params)
14
- body = response.body
15
-
16
- Resources::ImportCollection.new(
17
- data: body["data"],
18
- has_more: body["hasMore"],
19
- next_cursor: body["nextCursor"]
20
- )
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Exa
4
- module Services
5
- module Websets
6
- class UpdateImport
7
- def initialize(connection, id:, **params)
8
- @connection = connection
9
- @id = id
10
- @params = params
11
- end
12
-
13
- def call
14
- response = @connection.patch("/websets/v0/imports/#{@id}", @params)
15
- body = response.body
16
-
17
- Resources::Import.new(
18
- id: body["id"],
19
- object: body["object"],
20
- status: body["status"],
21
- format: body["format"],
22
- entity: body["entity"],
23
- title: body["title"],
24
- count: body["count"],
25
- metadata: body["metadata"],
26
- failed_reason: body["failedReason"],
27
- failed_at: body["failedAt"],
28
- failed_message: body["failedMessage"],
29
- created_at: body["createdAt"],
30
- updated_at: body["updatedAt"],
31
- upload_url: body["uploadUrl"],
32
- upload_valid_until: body["uploadValidUntil"]
33
- )
34
- end
35
- end
36
- end
37
- end
38
- end