diff --git a/src/engine/Engine.js b/src/engine/Engine.js index d1c0201..d9095a0 100644 --- a/src/engine/Engine.js +++ b/src/engine/Engine.js @@ -283,15 +283,15 @@ class Engine { const hydrateModelList = async (property, modelToProcess, name) => { const subModelClass = getSubModelClass(modelToProcess, name, true); - const newModelList = await Promise.all(property.map(async subModel => { + const newModelList = await Promise.all(property.map(subModel => { if (hydratedModels[subModel.id]) { return hydratedModels[subModel.id]; } - return await this.get(subModelClass, subModel.id); + return this.get(subModelClass, subModel.id); })); - return await Promise.all(newModelList.map(async subModel => { + return Promise.all(newModelList.map(async subModel => { if (hydratedModels[subModel.id]) { return hydratedModels[subModel.id]; } @@ -312,7 +312,7 @@ class Engine { return isArray ? constructorField._items : constructorField; } - return await hydrateModel(await this.get(model.constructor, model.id)); + return hydrateModel(await this.get(model.constructor, model.id)); } /** diff --git a/src/engine/HTTPEngine.js b/src/engine/HTTPEngine.js index 8e63615..841ceb6 100644 --- a/src/engine/HTTPEngine.js +++ b/src/engine/HTTPEngine.js @@ -126,7 +126,7 @@ class HTTPEngine extends Engine { * * @throws {HTTPRequestFailedError} Thrown if the fetch request fails. */ - static async getById(id) { + static getById(id) { this.checkConfiguration(); const url = new URL([ @@ -135,7 +135,7 @@ class HTTPEngine extends Engine { `${id}.json`, ].filter(e => Boolean(e)).join('/')); - return await this._processFetch(url, this._getReadOptions()); + return this._processFetch(url, this._getReadOptions()); } /** @@ -177,7 +177,7 @@ class HTTPEngine extends Engine { '_index.json', ].filter(e => Boolean(e)).join('/')); - return await this._processFetch(url, { + return this._processFetch(url, { ...this._getWriteOptions(), body: JSON.stringify({ ...await this.getIndex(location), @@ -199,7 +199,7 @@ class HTTPEngine extends Engine { * @param {Model.constructor?} model - The model in the host where the index is stored. * @returns {Promise} The index data in JSON format. */ - static async getIndex(model) { + static getIndex(model) { const url = new URL([ this.configuration.host, this.configuration.prefix, @@ -207,7 +207,7 @@ class HTTPEngine extends Engine { '_index.json', ].filter(e => Boolean(e)).join('/')); - return await this._processFetch(url, this._getReadOptions(), {}); + return this._processFetch(url, this._getReadOptions(), {}); } /** @@ -216,7 +216,7 @@ class HTTPEngine extends Engine { * @param {Model.constructor} model - The model whose compiled search index to retrieve. * @returns {Promise} The compiled search index in JSON format. */ - static async getSearchIndexCompiled(model) { + static getSearchIndexCompiled(model) { const url = new URL([ this.configuration.host, this.configuration.prefix, @@ -224,7 +224,7 @@ class HTTPEngine extends Engine { '_search_index.json', ].join('/')); - return await this._processFetch(url, this._getReadOptions()); + return this._processFetch(url, this._getReadOptions()); } /** @@ -233,7 +233,7 @@ class HTTPEngine extends Engine { * @param {Model.constructor} model - The model whose raw search index to retrieve. * @returns {Promise} The raw search index in JSON format, or an empty object if not found. */ - static async getSearchIndexRaw(model) { + static getSearchIndexRaw(model) { const url = new URL([ this.configuration.host, this.configuration.prefix, @@ -241,7 +241,7 @@ class HTTPEngine extends Engine { '_search_index_raw.json', ].join('/')); - return await this._processFetch(url, this._getReadOptions()).catch(() => ({})); + return this._processFetch(url, this._getReadOptions()).catch(() => ({})); } /** @@ -253,7 +253,7 @@ class HTTPEngine extends Engine { * * @throws {HTTPRequestFailedError} Thrown if the PUT request fails. */ - static async putSearchIndexCompiled(model, compiledIndex) { + static putSearchIndexCompiled(model, compiledIndex) { const url = new URL([ this.configuration.host, this.configuration.prefix, @@ -276,7 +276,7 @@ class HTTPEngine extends Engine { * * @throws {HTTPRequestFailedError} Thrown if the PUT request fails. */ - static async putSearchIndexRaw(model, rawIndex) { + static putSearchIndexRaw(model, rawIndex) { const url = new URL([ this.configuration.host, this.configuration.prefix, @@ -284,7 +284,7 @@ class HTTPEngine extends Engine { '_search_index_raw.json', ].filter(e => Boolean(e)).join('/')); - return await this._processFetch(url, { + return this._processFetch(url, { ...this._getWriteOptions(), body: JSON.stringify(rawIndex), }); diff --git a/src/engine/S3Engine.js b/src/engine/S3Engine.js index 8dba80c..0637ed5 100644 --- a/src/engine/S3Engine.js +++ b/src/engine/S3Engine.js @@ -153,9 +153,9 @@ class S3Engine extends Engine { * @param {Model.constructor} model - The model whose search index to retrieve. * @returns {Promise} The compiled search index. */ - static async getSearchIndexCompiled(model) { - return await this.configuration.client.send(new GetObjectCommand({ - Key: [this.configuration.prefix, model.name, '_search_index.json'].join('/'), + static getSearchIndexCompiled(model) { + return this.configuration.client.send(new GetObjectCommand({ + Key: [this.configuration.prefix, model.toString(), '_search_index.json'].join('/'), Bucket: this.configuration.bucket, })).then(data => data.Body.transformToString()) .then(JSON.parse); @@ -167,8 +167,8 @@ class S3Engine extends Engine { * @param {Model.constructor} model - The model whose raw search index to retrieve. * @returns {Promise} The raw search index, or an empty object if not found. */ - static async getSearchIndexRaw(model) { - return await this.configuration.client.send(new GetObjectCommand({ + static getSearchIndexRaw(model) { + return this.configuration.client.send(new GetObjectCommand({ Key: [this.configuration.prefix, model.toString(), '_search_index_raw.json'].join('/'), Bucket: this.configuration.bucket, })).then(data => data.Body.transformToString())