Skip to content

Commit

Permalink
Update http methods in settings routes v0.28 (#1262)
Browse files Browse the repository at this point in the history
* Update tasks API

* Add additional tests on index tasks routes

* Update readme api references

* Make task typs an enum

* Update wait for tasks tests

* Update getTasks filter to arrays

* Fix taskUid parameter naming in waitForTask

* Make task tests more relevant

* Update the tests impacted by the task api changes

* Keep task destructing in tests

* Fix linting

* Wrap get indexes routes in results object

* Rebase

* Change http methods on route settings route

* Fix wrong http methods on documents routes
  • Loading branch information
bidoubiwa authored Jun 20, 2022
1 parent b8cec6e commit 6fcd2a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class Index<T = Record<string, any>> {
*/
async updateSettings(settings: Settings): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings`
return await this.httpRequest.post(url, settings)
return await this.httpRequest.patch(url, settings)
}

/**
Expand Down Expand Up @@ -523,7 +523,7 @@ class Index<T = Record<string, any>> {
*/
async updateSynonyms(synonyms: Synonyms): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/synonyms`
return await this.httpRequest.post(url, synonyms)
return await this.httpRequest.put(url, synonyms)
}

/**
Expand Down Expand Up @@ -561,7 +561,7 @@ class Index<T = Record<string, any>> {
*/
async updateStopWords(stopWords: StopWords): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/stop-words`
return await this.httpRequest.post(url, stopWords)
return await this.httpRequest.put(url, stopWords)
}

/**
Expand Down Expand Up @@ -599,7 +599,7 @@ class Index<T = Record<string, any>> {
*/
async updateRankingRules(rankingRules: RankingRules): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/ranking-rules`
return await this.httpRequest.post(url, rankingRules)
return await this.httpRequest.put(url, rankingRules)
}

/**
Expand Down Expand Up @@ -639,7 +639,7 @@ class Index<T = Record<string, any>> {
distinctAttribute: DistinctAttribute
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/distinct-attribute`
return await this.httpRequest.post(url, distinctAttribute)
return await this.httpRequest.put(url, distinctAttribute)
}

/**
Expand Down Expand Up @@ -679,7 +679,7 @@ class Index<T = Record<string, any>> {
filterableAttributes: FilterableAttributes
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.post(url, filterableAttributes)
return await this.httpRequest.put(url, filterableAttributes)
}

/**
Expand Down Expand Up @@ -719,7 +719,7 @@ class Index<T = Record<string, any>> {
sortableAttributes: SortableAttributes
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/sortable-attributes`
return await this.httpRequest.post(url, sortableAttributes)
return await this.httpRequest.put(url, sortableAttributes)
}

/**
Expand Down Expand Up @@ -759,7 +759,7 @@ class Index<T = Record<string, any>> {
searchableAttributes: SearchableAttributes
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/searchable-attributes`
return await this.httpRequest.post(url, searchableAttributes)
return await this.httpRequest.put(url, searchableAttributes)
}

/**
Expand Down Expand Up @@ -799,7 +799,7 @@ class Index<T = Record<string, any>> {
displayedAttributes: DisplayedAttributes
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/displayed-attributes`
return await this.httpRequest.post(url, displayedAttributes)
return await this.httpRequest.put(url, displayedAttributes)
}

/**
Expand Down Expand Up @@ -839,7 +839,7 @@ class Index<T = Record<string, any>> {
typoTolerance: TypoTolerance
): Promise<EnqueuedTask> {
const url = `indexes/${this.uid}/settings/typo-tolerance`
return await this.httpRequest.post(url, typoTolerance)
return await this.httpRequest.patch(url, typoTolerance)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/synonyms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe.each([{ permission: 'Master' }, { permission: 'Private' }])(
({ permission }) => {
beforeEach(async () => {
const client = await getClient('Master')
const { uid } = await client.index(index.uid).addDocuments(dataset)
await client.waitForTask(uid)
const { taskUid } = await client.index(index.uid).addDocuments(dataset)
await client.waitForTask(taskUid)
})

test(`${permission} key: Get default synonyms`, async () => {
Expand Down
1 change: 0 additions & 1 deletion tests/utils/meilisearch-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const clearAllIndexes = async (config: Config): Promise<void> => {
const { taskUid } = await client.index(indexUid).delete()
taskIds.push(taskUid)
}

await client.waitForTasks(taskIds)
}

Expand Down

0 comments on commit 6fcd2a3

Please sign in to comment.