diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 5558d2d34..8182e0b62 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -84,8 +84,7 @@ update_settings_1: |- synonyms: { 'wolverine': ['xmen', 'logan'], 'logan': ['wolverine'] - }, - acceptNewFields: false + } }) reset_settings_1: |- client.getIndex('movies').resetSettings() @@ -148,10 +147,6 @@ update_displayed_attributes_1: |- ]) reset_displayed_attributes_1: |- client.getIndex('movies').resetDisplayedAttributes() -get_accept_new_fields_1: |- - client.getIndex('movies').getAcceptNewFields() -update_accept_new_fields_1: |- - client.getIndex('movies').updateAcceptNewFields(false) get_index_stats_1: |- client.getIndex('movies').getStats() get_indexes_stats_1: |- @@ -295,10 +290,6 @@ settings_guide_displayed_1: |- 'rank' ] }) -settings_guide_accept_new_fields_1: |- - client.getIndex('movies').settings({ - acceptNewFields: false - }) add_movies_json_1: |- const movies = require('./movies.json') index.addDocuments(movies).then((res) => console.log(res)) diff --git a/README.md b/README.md index d7e9c1a6a..11b4dba83 100644 --- a/README.md +++ b/README.md @@ -474,14 +474,6 @@ If you want to know more about the development workflow or want to contribute, p - Reset Displayed Attributes `index.resetDisplayedAttributes(): Promise` -### Accept new fields - -- Get Accept new fields - `index.getAcceptNewFields(): Promise` - -- Update Accept new fields - `index.updateAcceptNewFields(acceptNewFields: boolean): Promise` - ### Keys - Get keys diff --git a/src/index.ts b/src/index.ts index a0b621165..bd443a3f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -598,34 +598,6 @@ class Index extends MeiliAxiosWrapper implements Types.IndexInterface { return await this.delete(url) } - - /// - /// ACCEPT NEW FIELDS - /// - - /** - * Get the accept-new-fields value. - * @memberof Index - * @method getAcceptNewFields - */ - async getAcceptNewFields(): Promise { - const url = `/indexes/${this.uid}/settings/accept-new-fields` - - return await this.get(url) - } - - /** - * Update the accept-new-fields value. - * @memberof Index - * @method updateAcceptNewFields - */ - async updateAcceptNewFields( - acceptNewFields: boolean - ): Promise { - const url = `/indexes/${this.uid}/settings/accept-new-fields` - - return await this.post(url, acceptNewFields) - } } export { Index } diff --git a/src/types.ts b/src/types.ts index 803d131f6..02d468711 100644 --- a/src/types.ts +++ b/src/types.ts @@ -163,7 +163,6 @@ export interface Settings { synonyms?: { [field: string]: string[] } - acceptNewFields?: boolean } /* @@ -344,8 +343,6 @@ export interface IndexInterface extends MeiliAxiosWrapperInterface { displayedAttributes: string[] ) => Promise resetDisplayedAttributes: () => Promise - getAcceptNewFields: () => Promise - updateAcceptNewFields: (acceptNewFields: boolean) => Promise } export interface MeiliAxiosWrapperInterface { diff --git a/tests/accept_new_fields_tests.ts b/tests/accept_new_fields_tests.ts deleted file mode 100644 index 2f68986c9..000000000 --- a/tests/accept_new_fields_tests.ts +++ /dev/null @@ -1,76 +0,0 @@ -import * as Types from '../src/types' -import { - clearAllIndexes, - config, - masterClient, - privateClient, - publicClient, - anonymousClient, - PUBLIC_KEY, -} from './meilisearch-test-utils' - -const index = { - uid: 'movies_test', -} - -jest.setTimeout(100 * 1000) - -afterAll(() => { - return clearAllIndexes(config) -}) - -describe.each([ - { client: masterClient, permission: 'Master' }, - { client: privateClient, permission: 'Private' }, -])('Test on accept-new-fields', ({ client, permission }) => { - beforeAll(async () => { - await clearAllIndexes(config) - await masterClient.createIndex(index.uid) - }) - test(`${permission} key: Get accept new fields to be true`, async () => { - await client - .getIndex(index.uid) - .getAcceptNewFields() - .then((response: boolean) => { - expect(response).toEqual(true) - }) - }) - test(`${permission} key: Update accept new fields to false`, async () => { - const { updateId } = await client - .getIndex(index.uid) - .updateAcceptNewFields(false) - .then((response: Types.EnqueuedUpdate) => { - expect(response).toHaveProperty('updateId', expect.any(Number)) - return response - }) - await client.getIndex(index.uid).waitForPendingUpdate(updateId) - await client - .getIndex(index.uid) - .getAcceptNewFields() - .then((response: boolean) => { - expect(response).toEqual(false) - }) - }) -}) - -describe.each([{ client: publicClient, permission: 'Public' }])( - 'Test on accept-new-fields', - ({ client, permission }) => { - test(`${permission} key: try to get accept-new-fields and be denied`, async () => { - await expect( - client.getIndex(index.uid).getAcceptNewFields() - ).rejects.toThrowError(`Invalid API key: ${PUBLIC_KEY}`) - }) - } -) - -describe.each([{ client: anonymousClient, permission: 'No' }])( - 'Test on accept-new-fields', - ({ client, permission }) => { - test(`${permission} key: try to get accept-new-fields and be denied`, async () => { - await expect( - client.getIndex(index.uid).getAcceptNewFields() - ).rejects.toThrowError(`You must have an authorization token`) - }) - } -) diff --git a/tests/displayed_attributes_tests.ts b/tests/displayed_attributes_tests.ts index 2f255e5a5..b085a5d33 100644 --- a/tests/displayed_attributes_tests.ts +++ b/tests/displayed_attributes_tests.ts @@ -50,7 +50,7 @@ describe.each([ .getIndex(index.uid) .getDisplayedAttributes() .then((response: string[]) => { - expect(response.sort()).toEqual(Object.keys(dataset[0]).sort()) + expect(response).toEqual(['*']) }) }) test(`${permission} key: Update displayed attributes`, async () => { @@ -83,7 +83,7 @@ describe.each([ .getIndex(index.uid) .getDisplayedAttributes() .then((response: string[]) => { - expect(response.sort()).toEqual(Object.keys(dataset[0]).sort()) + expect(response).toEqual(['*']) }) }) }) diff --git a/tests/get_or_create_tests.ts b/tests/get_or_create_tests.ts index 426ece725..2b163c332 100644 --- a/tests/get_or_create_tests.ts +++ b/tests/get_or_create_tests.ts @@ -51,9 +51,9 @@ describe.each([{ client: publicClient, permission: 'Public' }])( 'Test on getOrCreateIndex', ({ client, permission }) => { test(`${permission} key: try to getOrCreateIndex and be denied`, async () => { - await expect( - client.getIndex(index.uid).getAcceptNewFields() - ).rejects.toThrowError(`Invalid API key: ${PUBLIC_KEY}`) + await expect(client.getOrCreateIndex(index.uid)).rejects.toThrowError( + `Invalid API key: ${PUBLIC_KEY}` + ) }) } ) @@ -62,9 +62,9 @@ describe.each([{ client: anonymousClient, permission: 'No' }])( 'Test on getOrCreateIndex', ({ client, permission }) => { test(`${permission} key: try to getOrCreateIndex and be denied`, async () => { - await expect( - client.getIndex(index.uid).getAcceptNewFields() - ).rejects.toThrowError(`You must have an authorization token`) + await expect(client.getOrCreateIndex(index.uid)).rejects.toThrowError( + `You must have an authorization token` + ) }) } ) diff --git a/tests/searchable_attributes_tests.ts b/tests/searchable_attributes_tests.ts index d56f4cabd..d2920b882 100644 --- a/tests/searchable_attributes_tests.ts +++ b/tests/searchable_attributes_tests.ts @@ -50,7 +50,7 @@ describe.each([ .getIndex(index.uid) .getSearchableAttributes() .then((response: string[]) => { - expect(response.sort()).toEqual(Object.keys(dataset[0]).sort()) + expect(response).toEqual(['*']) }) }) test(`${permission} key: Update searchable attributes`, async () => { @@ -83,7 +83,7 @@ describe.each([ .getIndex(index.uid) .getSearchableAttributes() .then((response: string[]) => { - expect(response.sort()).toEqual(Object.keys(dataset[0]).sort()) + expect(response).toEqual(['*']) }) }) }) diff --git a/tests/settings_tests.ts b/tests/settings_tests.ts index 6835c12d3..f577ef31d 100644 --- a/tests/settings_tests.ts +++ b/tests/settings_tests.ts @@ -47,7 +47,6 @@ const defaultSettingsEmpty = { displayedAttributes: [], stopWords: [], synonyms: {}, - acceptNewFields: true, } const defaultSettings = { @@ -57,7 +56,6 @@ const defaultSettings = { displayedAttributes: ['comment', 'title', 'id'], stopWords: [], synonyms: {}, - acceptNewFields: true, } jest.setTimeout(100 * 1000) @@ -88,22 +86,10 @@ describe.each([ .then((response: Types.Settings) => { expect(response).toHaveProperty('rankingRules', defaultRankingRules) expect(response).toHaveProperty('distinctAttribute', null) - expect(response).toHaveProperty('searchableAttributes', [ - 'id', - 'title', - 'comment', - ]) - expect(response).toHaveProperty( - 'displayedAttributes', - expect.any(Array) - ) - const sortedAttributes = response.displayedAttributes - ? response.displayedAttributes.sort() - : undefined - expect(sortedAttributes).toEqual(['id', 'title', 'comment'].sort()) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', []) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -114,11 +100,10 @@ describe.each([ .then((response: Types.Settings) => { expect(response).toHaveProperty('rankingRules', defaultRankingRules) expect(response).toHaveProperty('distinctAttribute', null) - expect(response).toHaveProperty('searchableAttributes', ['id']) - expect(response).toHaveProperty('displayedAttributes', ['id']) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', []) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -149,17 +134,10 @@ describe.each([ 'distinctAttribute', newSettings.distinctAttribute ) - expect(response).toHaveProperty( - 'searchableAttributes', - defaultSettings.searchableAttributes - ) - expect(response).toHaveProperty( - 'displayedAttributes', - expect.any(Array) - ) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', newSettings.stopWords) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -189,14 +167,10 @@ describe.each([ 'distinctAttribute', newSettings.distinctAttribute ) - expect(response).toHaveProperty('searchableAttributes', ['id']) - expect(response).toHaveProperty( - 'displayedAttributes', - expect.any(Array) - ) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', newSettings.stopWords) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -215,25 +189,10 @@ describe.each([ .then((response: Types.Settings) => { expect(response).toHaveProperty('rankingRules', defaultRankingRules) expect(response).toHaveProperty('distinctAttribute', null) - expect(response).toHaveProperty( - 'searchableAttributes', - expect.any(Array) - ) - const sortedSearchable = response.searchableAttributes - ? response.searchableAttributes.sort() - : undefined - expect(sortedSearchable).toEqual(['id', 'title', 'comment'].sort()) - expect(response).toHaveProperty( - 'displayedAttributes', - expect.any(Array) - ) - const sortedDisplayed = response.displayedAttributes - ? response.displayedAttributes.sort() - : undefined - expect(sortedDisplayed).toEqual(['id', 'title', 'comment'].sort()) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', []) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -252,25 +211,10 @@ describe.each([ .then((response: Types.Settings) => { expect(response).toHaveProperty('rankingRules', defaultRankingRules) expect(response).toHaveProperty('distinctAttribute', null) - expect(response).toHaveProperty( - 'searchableAttributes', - expect.any(Array) - ) - const sortedSearchable = response.searchableAttributes - ? response.searchableAttributes.sort() - : undefined - expect(sortedSearchable).toEqual(['id', 'title'].sort()) - expect(response).toHaveProperty( - 'displayedAttributes', - expect.any(Array) - ) - const sortedDisplayed = response.displayedAttributes - ? response.displayedAttributes.sort() - : undefined - expect(sortedDisplayed).toEqual(['id', 'title'].sort()) + expect(response).toHaveProperty('searchableAttributes', ['*']) + expect(response).toHaveProperty('displayedAttributes', ['*']) expect(response).toHaveProperty('stopWords', []) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -305,7 +249,6 @@ describe.each([ ) expect(response).toHaveProperty('stopWords', defaultSettings.stopWords) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) @@ -340,7 +283,6 @@ describe.each([ ) expect(response).toHaveProperty('stopWords', defaultSettings.stopWords) expect(response).toHaveProperty('synonyms', {}) - expect(response).toHaveProperty('acceptNewFields', true) }) }) })