Skip to content

Commit

Permalink
Revert some type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
flevi29 committed Oct 11, 2024
1 parent 3854e13 commit d73d58d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
44 changes: 22 additions & 22 deletions src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing record of synonym mappings
*/
async getSynonyms(): Promise<Synonyms> {
async getSynonyms(): Promise<Record<string, string[]>> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/synonyms`,
})) as Synonyms;
})) as Record<string, string[]>;
}

/**
Expand Down Expand Up @@ -780,10 +780,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of stop-words
*/
async getStopWords(): Promise<NonNullable<StopWords>> {
async getStopWords(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/stop-words`,
})) as NonNullable<StopWords>;
})) as string[];
}

/**
Expand Down Expand Up @@ -823,10 +823,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of ranking-rules
*/
async getRankingRules(): Promise<RankingRules> {
async getRankingRules(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/ranking-rules`,
})) as RankingRules;
})) as string[];
}

/**
Expand Down Expand Up @@ -912,10 +912,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing an array of filterable-attributes
*/
async getFilterableAttributes(): Promise<FilterableAttributes> {
async getFilterableAttributes(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/filterable-attributes`,
})) as FilterableAttributes;
})) as string[];
}

/**
Expand Down Expand Up @@ -958,10 +958,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of sortable-attributes
*/
async getSortableAttributes(): Promise<SortableAttributes> {
async getSortableAttributes(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/sortable-attributes`,
})) as SortableAttributes;
})) as string[];
}

/**
Expand Down Expand Up @@ -1004,10 +1004,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of searchable-attributes
*/
async getSearchableAttributes(): Promise<SearchableAttributes> {
async getSearchableAttributes(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/searchable-attributes`,
})) as SearchableAttributes;
})) as string[];
}

/**
Expand Down Expand Up @@ -1050,10 +1050,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of displayed-attributes
*/
async getDisplayedAttributes(): Promise<NonNullable<DisplayedAttributes>> {
async getDisplayedAttributes(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/displayed-attributes`,
})) as NonNullable<DisplayedAttributes>;
})) as string[];
}

/**
Expand Down Expand Up @@ -1096,10 +1096,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing the typo tolerance settings.
*/
async getTypoTolerance(): Promise<NonNullable<TypoTolerance>> {
async getTypoTolerance(): Promise<TypoTolerance> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/typo-tolerance`,
})) as NonNullable<TypoTolerance>;
})) as TypoTolerance;
}

/**
Expand Down Expand Up @@ -1185,10 +1185,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of separator tokens
*/
async getSeparatorTokens(): Promise<SeparatorTokens> {
async getSeparatorTokens(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/separator-tokens`,
})) as SeparatorTokens;
})) as string[];
}

/**
Expand Down Expand Up @@ -1230,10 +1230,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing array of non-separator tokens
*/
async getNonSeparatorTokens(): Promise<NonSeparatorTokens> {
async getNonSeparatorTokens(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/non-separator-tokens`,
})) as NonSeparatorTokens;
})) as string[];
}

/**
Expand Down Expand Up @@ -1275,10 +1275,10 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*
* @returns Promise containing the dictionary settings
*/
async getDictionary(): Promise<NonNullable<Dictionary>> {
async getDictionary(): Promise<string[]> {
return (await this.httpRequest.get({
relativeURL: `indexes/${this.uid}/settings/dictionary`,
})) as NonNullable<Dictionary>;
})) as string[];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/synonyms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(

test(`${permission} key: Get default synonyms`, async () => {
const client = await getClient(permission);
const response: object = await client.index(index.uid).getSynonyms();
const response = await client.index(index.uid).getSynonyms();

expect(response).toEqual({});
});
Expand Down
5 changes: 1 addition & 4 deletions tests/task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
test(`${permission} key: Try to cancel without filters and fail`, async () => {
const client = await getClient(permission);

await expect(
// @ts-expect-error testing wrong argument type
client.cancelTasks(),
).rejects.toHaveProperty(
await expect(client.cancelTasks()).rejects.toHaveProperty(
"cause.code",
ErrorStatusCode.MISSING_TASK_FILTERS,
);
Expand Down

0 comments on commit d73d58d

Please sign in to comment.