Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
871e117
feat(test): add helper method for deprecated tests
tharropoulos Aug 20, 2025
8cba546
feat(test): skip old analytics and synonym tests after v30+
tharropoulos Aug 20, 2025
cd18ab5
feat(synonyms): add synonym set classes
tharropoulos Aug 20, 2025
b1f2c81
feat: register synonym set classes to client object
tharropoulos Aug 20, 2025
aacb80d
test: add test suite for synonym sets
tharropoulos Aug 20, 2025
9c0e948
fix(synonyms): rename `synonyms` to `items` inside synonym sets
tharropoulos Sep 23, 2025
5b13517
feat(curation): add curation set classes
tharropoulos Sep 23, 2025
fce699c
feat: register curation set classes to client object
tharropoulos Sep 23, 2025
dce7a01
test(curation): add test suite for curation sets
tharropoulos Sep 23, 2025
452e805
feat(analytics): add definitions for old analytic events API
tharropoulos Aug 20, 2025
d86cc89
feat(analytics): rename old API to analytics_v1
tharropoulos Aug 20, 2025
e188fac
feat(analytics): add new analytics API
tharropoulos Aug 20, 2025
696026a
test(analytics): add tests for analytic class instantation
tharropoulos Aug 20, 2025
75a1437
test(analytics): add integration tests for old analytics API
tharropoulos Aug 20, 2025
306ce55
test(analytics): add integration tests for new analytics API
tharropoulos Aug 20, 2025
74cf59d
ci: upgrade typesense to v30
tharropoulos Oct 21, 2025
15deb9b
fix(test): also match non-prefixed `v` versions on check
tharropoulos Oct 21, 2025
94b170d
fix(test): update expected schema to include `truncate_len`
tharropoulos Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
ruby-version: ['3.0', '3.2', '3.3', '3.4']
services:
typesense:
image: typesense/typesense:29.0
image: typesense/typesense:30.0.alpha1
ports:
- 8108:8108
volumes:
Expand Down
11 changes: 11 additions & 0 deletions lib/typesense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ module Typesense
require_relative 'typesense/override'
require_relative 'typesense/synonyms'
require_relative 'typesense/synonym'
require_relative 'typesense/synonym_sets'
require_relative 'typesense/synonym_set'
require_relative 'typesense/aliases'
require_relative 'typesense/alias'
require_relative 'typesense/keys'
require_relative 'typesense/key'
require_relative 'typesense/multi_search'
require_relative 'typesense/analytics'
require_relative 'typesense/analytics_events'
require_relative 'typesense/analytics_rules'
require_relative 'typesense/analytics_rule'
require_relative 'typesense/analytics_v1'
require_relative 'typesense/analytics_events_v1'
require_relative 'typesense/analytics_rules_v1'
require_relative 'typesense/analytics_rule_v1'
require_relative 'typesense/presets'
require_relative 'typesense/preset'
require_relative 'typesense/debug'
Expand All @@ -37,3 +44,7 @@ module Typesense
require_relative 'typesense/stemming_dictionary'
require_relative 'typesense/nl_search_models'
require_relative 'typesense/nl_search_model'
require_relative 'typesense/curation_sets'
require_relative 'typesense/curation_set'
require_relative 'typesense/curation_set_items'
require_relative 'typesense/curation_set_item'
4 changes: 4 additions & 0 deletions lib/typesense/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ def initialize(api_call)
def rules
@rules ||= AnalyticsRules.new(@api_call)
end

def events
@events ||= AnalyticsEvents.new(@api_call)
end
end
end
19 changes: 19 additions & 0 deletions lib/typesense/analytics_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Typesense
class AnalyticsEvents
RESOURCE_PATH = '/analytics/events'

def initialize(api_call)
@api_call = api_call
end

def create(params)
@api_call.post(self.class::RESOURCE_PATH, params)
end

def retrieve(params = {})
@api_call.get(self.class::RESOURCE_PATH, params)
end
end
end
21 changes: 21 additions & 0 deletions lib/typesense/analytics_events_v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Typesense
class AnalyticsEventsV1
RESOURCE_PATH = '/analytics/events'

def initialize(api_call)
@api_call = api_call
end

def create(params)
@api_call.post(endpoint_path, params)
end

private

def endpoint_path(operation = nil)
"#{AnalyticsEventsV1::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
end
end
end
4 changes: 4 additions & 0 deletions lib/typesense/analytics_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def delete
@api_call.delete(endpoint_path)
end

def update(params)
@api_call.put(endpoint_path, params)
end

private

def endpoint_path
Expand Down
24 changes: 24 additions & 0 deletions lib/typesense/analytics_rule_v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module Typesense
class AnalyticsRuleV1
def initialize(rule_name, api_call)
@rule_name = rule_name
@api_call = api_call
end

def retrieve
@api_call.get(endpoint_path)
end

def delete
@api_call.delete(endpoint_path)
end

private

def endpoint_path
"#{AnalyticsRulesV1::RESOURCE_PATH}/#{URI.encode_www_form_component(@rule_name)}"
end
end
end
19 changes: 10 additions & 9 deletions lib/typesense/analytics_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ class AnalyticsRules
RESOURCE_PATH = '/analytics/rules'

def initialize(api_call)
@api_call = api_call
@analytics_rules = {}
@api_call = api_call
end

def upsert(rule_name, params)
@api_call.put(endpoint_path(rule_name), params)
def create(rules)
@api_call.post(self.class::RESOURCE_PATH, rules)
end

def retrieve
@api_call.get(endpoint_path)
@api_call.get(self.class::RESOURCE_PATH)
end

def [](rule_name)
@analytics_rules[rule_name] ||= AnalyticsRule.new(rule_name, @api_call)
AnalyticsRule.new(rule_name, @api_call)
end

private
def respond_to_missing?(_method_name, _include_private = false)
Copy link
Member

@jasonbosco jasonbosco Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the pattern we have in all the other resources for array access. Any reason you added it just for this and the new resources?

I'd prefer we not add it, so there's only one way to access individual objects across all types of resources.

true
end

def endpoint_path(operation = nil)
"#{AnalyticsRules::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
def method_missing(method_name, *_args, &_block)
self[method_name.to_s]
end
end
end
30 changes: 30 additions & 0 deletions lib/typesense/analytics_rules_v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

module Typesense
class AnalyticsRulesV1
RESOURCE_PATH = '/analytics/rules'

def initialize(api_call)
@api_call = api_call
@analytics_rules = {}
end

def upsert(rule_name, params)
@api_call.put(endpoint_path(rule_name), params)
end

def retrieve
@api_call.get(endpoint_path)
end

def [](rule_name)
@analytics_rules[rule_name] ||= AnalyticsRuleV1.new(rule_name, @api_call)
end

private

def endpoint_path(operation = nil)
"#{AnalyticsRulesV1::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
end
end
end
19 changes: 19 additions & 0 deletions lib/typesense/analytics_v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Typesense
class AnalyticsV1
RESOURCE_PATH = '/analytics'

def initialize(api_call)
@api_call = api_call
end

def rules
@rules ||= AnalyticsRulesV1.new(@api_call)
end

def events
@events ||= AnalyticsEventsV1.new(@api_call)
end
end
end
5 changes: 4 additions & 1 deletion lib/typesense/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Typesense
class Client
attr_reader :configuration, :collections, :aliases, :keys, :debug, :health, :metrics, :stats, :operations,
:multi_search, :analytics, :presets, :stemming, :nl_search_models
:multi_search, :analytics, :analytics_v1, :presets, :stemming, :nl_search_models, :synonym_sets, :curation_sets

def initialize(options = {})
@configuration = Configuration.new(options)
Expand All @@ -18,9 +18,12 @@ def initialize(options = {})
@stats = Stats.new(@api_call)
@operations = Operations.new(@api_call)
@analytics = Analytics.new(@api_call)
@analytics_v1 = AnalyticsV1.new(@api_call)
@stemming = Stemming.new(@api_call)
@presets = Presets.new(@api_call)
@nl_search_models = NlSearchModels.new(@api_call)
@synonym_sets = SynonymSets.new(@api_call)
@curation_sets = CurationSets.new(@api_call)
end
end
end
31 changes: 31 additions & 0 deletions lib/typesense/curation_set.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module Typesense
class CurationSet
attr_reader :items

def initialize(curation_set_name, api_call)
@curation_set_name = curation_set_name
@api_call = api_call
@items = CurationSetItems.new(@curation_set_name, @api_call)
end

def upsert(curation_set_data)
@api_call.put(endpoint_path, curation_set_data)
end

def retrieve
@api_call.get(endpoint_path)
end

def delete
@api_call.delete(endpoint_path)
end

private

def endpoint_path
"#{CurationSets::RESOURCE_PATH}/#{URI.encode_www_form_component(@curation_set_name)}"
end
end
end
29 changes: 29 additions & 0 deletions lib/typesense/curation_set_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Typesense
class CurationSetItem
def initialize(curation_set_name, item_id, api_call)
@curation_set_name = curation_set_name
@item_id = item_id
@api_call = api_call
end

def retrieve
@api_call.get(endpoint_path)
end

def upsert(params)
@api_call.put(endpoint_path, params)
end

def delete
@api_call.delete(endpoint_path)
end

private

def endpoint_path
"#{CurationSets::RESOURCE_PATH}/#{URI.encode_www_form_component(@curation_set_name)}/items/#{URI.encode_www_form_component(@item_id)}"
end
end
end
33 changes: 33 additions & 0 deletions lib/typesense/curation_set_items.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module Typesense
class CurationSetItems
def initialize(curation_set_name, api_call)
@curation_set_name = curation_set_name
@api_call = api_call
@items = {}
end

def retrieve
@api_call.get(endpoint_path)
end

def [](item_id)
@items[item_id] ||= CurationSetItem.new(@curation_set_name, item_id, @api_call)
end

def respond_to_missing?(_method_name, _include_private = false)
true
end

def method_missing(method_name, *_args, &_block)
self[method_name.to_s]
end

private

def endpoint_path(operation = nil)
"#{CurationSets::RESOURCE_PATH}/#{URI.encode_www_form_component(@curation_set_name)}/items#{"/#{operation}" unless operation.nil?}"
end
end
end
31 changes: 31 additions & 0 deletions lib/typesense/curation_sets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module Typesense
class CurationSets
RESOURCE_PATH = '/curation_sets'

def initialize(api_call)
@api_call = api_call
end

def upsert(curation_set_name, curation_set_data)
@api_call.put("#{self.class::RESOURCE_PATH}/#{URI.encode_www_form_component(curation_set_name)}", curation_set_data)
end

def retrieve
@api_call.get(self.class::RESOURCE_PATH)
end

def [](curation_set_name)
CurationSet.new(curation_set_name, @api_call)
end

def respond_to_missing?(_method_name, _include_private = false)
true
end

def method_missing(method_name, *_args, &_block)
self[method_name.to_s]
end
end
end
24 changes: 24 additions & 0 deletions lib/typesense/synonym_set.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module Typesense
class SynonymSet
def initialize(synonym_set_name, api_call)
@synonym_set_name = synonym_set_name
@api_call = api_call
end

def retrieve
@api_call.get(endpoint_path)
end

def delete
@api_call.delete(endpoint_path)
end

private

def endpoint_path
"#{SynonymSets::RESOURCE_PATH}/#{URI.encode_www_form_component(@synonym_set_name)}"
end
end
end
Loading