-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat!: add v30 api breaking changes #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tharropoulos
wants to merge
18
commits into
typesense:master
Choose a base branch
from
tharropoulos:v30
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 8cba546
feat(test): skip old analytics and synonym tests after v30+
tharropoulos cd18ab5
feat(synonyms): add synonym set classes
tharropoulos b1f2c81
feat: register synonym set classes to client object
tharropoulos aacb80d
test: add test suite for synonym sets
tharropoulos 9c0e948
fix(synonyms): rename `synonyms` to `items` inside synonym sets
tharropoulos 5b13517
feat(curation): add curation set classes
tharropoulos fce699c
feat: register curation set classes to client object
tharropoulos dce7a01
test(curation): add test suite for curation sets
tharropoulos 452e805
feat(analytics): add definitions for old analytic events API
tharropoulos d86cc89
feat(analytics): rename old API to analytics_v1
tharropoulos e188fac
feat(analytics): add new analytics API
tharropoulos 696026a
test(analytics): add tests for analytic class instantation
tharropoulos 75a1437
test(analytics): add integration tests for old analytics API
tharropoulos 306ce55
test(analytics): add integration tests for new analytics API
tharropoulos 74cf59d
ci: upgrade typesense to v30
tharropoulos 15deb9b
fix(test): also match non-prefixed `v` versions on check
tharropoulos 94b170d
fix(test): update expected schema to include `truncate_len`
tharropoulos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.