Browse Source

style(elasticsearch-plugin): Apply Prettier to recent changes

Michael Bromley 4 years ago
parent
commit
9a75a60d34

+ 1 - 1
packages/elasticsearch-plugin/src/elasticsearch-index.service.ts

@@ -65,7 +65,7 @@ export class ElasticsearchIndexService implements OnApplicationBootstrap {
     }
     }
 
 
     reindex(ctx: RequestContext) {
     reindex(ctx: RequestContext) {
-        return this.updateIndexQueue.add({ type: 'reindex', ctx: ctx.serialize()});
+        return this.updateIndexQueue.add({ type: 'reindex', ctx: ctx.serialize() });
     }
     }
 
 
     updateProduct(ctx: RequestContext, product: Product) {
     updateProduct(ctx: RequestContext, product: Product) {

+ 2 - 1
packages/elasticsearch-plugin/src/elasticsearch-resolver.ts

@@ -12,7 +12,8 @@ import { ElasticsearchService } from './elasticsearch.service';
 import { ElasticSearchInput, SearchPriceData } from './types';
 import { ElasticSearchInput, SearchPriceData } from './types';
 
 
 @Resolver('SearchResponse')
 @Resolver('SearchResponse')
-export class ShopElasticSearchResolver implements Omit<SearchResolver, 'facetValues' | 'collections' | 'reindex' > {
+export class ShopElasticSearchResolver
+    implements Omit<SearchResolver, 'facetValues' | 'collections' | 'reindex'> {
     constructor(private elasticsearchService: ElasticsearchService) {}
     constructor(private elasticsearchService: ElasticsearchService) {}
 
 
     @Query()
     @Query()

+ 37 - 16
packages/elasticsearch-plugin/src/elasticsearch.service.ts

@@ -108,7 +108,9 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
                 Logger.verbose(`Index "${index}" exists`, loggerCtx);
                 Logger.verbose(`Index "${index}" exists`, loggerCtx);
 
 
                 const existingIndexSettingsResult = await this.client.indices.getSettings({ index });
                 const existingIndexSettingsResult = await this.client.indices.getSettings({ index });
-                const existingIndexSettings = existingIndexSettingsResult.body[Object.keys(existingIndexSettingsResult.body)[0]].settings.index;
+                const existingIndexSettings =
+                    existingIndexSettingsResult.body[Object.keys(existingIndexSettingsResult.body)[0]]
+                        .settings.index;
 
 
                 const tempName = new Date().getTime();
                 const tempName = new Date().getTime();
                 const nameSalt = Math.random().toString(36).substring(7);
                 const nameSalt = Math.random().toString(36).substring(7);
@@ -126,26 +128,45 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
                 const tempIndexSettingsResult = await this.client.indices.getSettings({ index: tempIndex });
                 const tempIndexSettingsResult = await this.client.indices.getSettings({ index: tempIndex });
                 const tempIndexSettings = tempIndexSettingsResult.body[tempIndex].settings.index;
                 const tempIndexSettings = tempIndexSettingsResult.body[tempIndex].settings.index;
 
 
-                const indexParamsToExclude = [`routing`, `number_of_shards`, `provided_name`,
-                    `creation_date`, `number_of_replicas`, `uuid`, `version`];
+                const indexParamsToExclude = [
+                    `routing`,
+                    `number_of_shards`,
+                    `provided_name`,
+                    `creation_date`,
+                    `number_of_replicas`,
+                    `uuid`,
+                    `version`,
+                ];
                 for (const param of indexParamsToExclude) {
                 for (const param of indexParamsToExclude) {
                     delete tempIndexSettings[param];
                     delete tempIndexSettings[param];
                     delete existingIndexSettings[param];
                     delete existingIndexSettings[param];
                 }
                 }
                 if (!equal(tempIndexSettings, existingIndexSettings))
                 if (!equal(tempIndexSettings, existingIndexSettings))
-                    Logger.warn(`Index "${index}" settings differs from index setting in vendure config! Consider re-indexing the data.`, loggerCtx);
+                    Logger.warn(
+                        `Index "${index}" settings differs from index setting in vendure config! Consider re-indexing the data.`,
+                        loggerCtx,
+                    );
                 else {
                 else {
                     const existingIndexMappingsResult = await this.client.indices.getMapping({ index });
                     const existingIndexMappingsResult = await this.client.indices.getMapping({ index });
-                    const existingIndexMappings = existingIndexMappingsResult.body[Object.keys(existingIndexMappingsResult.body)[0]].mappings;
+                    const existingIndexMappings =
+                        existingIndexMappingsResult.body[Object.keys(existingIndexMappingsResult.body)[0]]
+                            .mappings;
 
 
-                    const tempIndexMappingsResult = await this.client.indices.getMapping({ index: tempIndex });
+                    const tempIndexMappingsResult = await this.client.indices.getMapping({
+                        index: tempIndex,
+                    });
                     const tempIndexMappings = tempIndexMappingsResult.body[tempIndex].mappings;
                     const tempIndexMappings = tempIndexMappingsResult.body[tempIndex].mappings;
                     if (!equal(tempIndexMappings, existingIndexMappings))
                     if (!equal(tempIndexMappings, existingIndexMappings))
                         // tslint:disable-next-line:max-line-length
                         // tslint:disable-next-line:max-line-length
-                        Logger.warn(`Index "${index}" mapping differs from index mapping in vendure config! Consider re-indexing the data.`, loggerCtx);
+                        Logger.warn(
+                            `Index "${index}" mapping differs from index mapping in vendure config! Consider re-indexing the data.`,
+                            loggerCtx,
+                        );
                 }
                 }
 
 
-                await this.client.indices.delete({ index: [tempPrefix+`products`, tempPrefix+`variants`] });
+                await this.client.indices.delete({
+                    index: [tempPrefix + `products`, tempPrefix + `variants`],
+                });
             }
             }
         };
         };
 
 
@@ -449,17 +470,17 @@ export class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
     ): { productAsset: SearchResultAsset | undefined; productVariantAsset: SearchResultAsset | undefined } {
     ): { productAsset: SearchResultAsset | undefined; productVariantAsset: SearchResultAsset | undefined } {
         const productAsset: SearchResultAsset | undefined = source.productAssetId
         const productAsset: SearchResultAsset | undefined = source.productAssetId
             ? {
             ? {
-                id: source.productAssetId.toString(),
-                preview: source.productPreview,
-                focalPoint: source.productPreviewFocalPoint,
-            }
+                  id: source.productAssetId.toString(),
+                  preview: source.productPreview,
+                  focalPoint: source.productPreviewFocalPoint,
+              }
             : undefined;
             : undefined;
         const productVariantAsset: SearchResultAsset | undefined = source.productVariantAssetId
         const productVariantAsset: SearchResultAsset | undefined = source.productVariantAssetId
             ? {
             ? {
-                id: source.productVariantAssetId.toString(),
-                preview: source.productVariantPreview,
-                focalPoint: source.productVariantPreviewFocalPoint,
-            }
+                  id: source.productVariantAssetId.toString(),
+                  preview: source.productVariantPreview,
+                  focalPoint: source.productVariantPreviewFocalPoint,
+              }
             : undefined;
             : undefined;
         return { productAsset, productVariantAsset };
         return { productAsset, productVariantAsset };
     }
     }

+ 97 - 74
packages/elasticsearch-plugin/src/indexer.controller.ts

@@ -84,8 +84,7 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
         @Inject(ELASTIC_SEARCH_OPTIONS) private options: Required<ElasticsearchOptions>,
         @Inject(ELASTIC_SEARCH_OPTIONS) private options: Required<ElasticsearchOptions>,
         private productVariantService: ProductVariantService,
         private productVariantService: ProductVariantService,
         private configService: ConfigService,
         private configService: ConfigService,
-    ) {
-    }
+    ) {}
 
 
     onModuleInit(): any {
     onModuleInit(): any {
         const { host, port } = this.options;
         const { host, port } = this.options;
@@ -119,10 +118,10 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
      * Updates the search index only for the affected product.
      * Updates the search index only for the affected product.
      */
      */
     async assignProductToChannel({
     async assignProductToChannel({
-                                     ctx: rawContext,
-                                     productId,
-                                     channelId,
-                                 }: ProductChannelMessageData): Promise<boolean> {
+        ctx: rawContext,
+        productId,
+        channelId,
+    }: ProductChannelMessageData): Promise<boolean> {
         await this.updateProductsInternal([productId]);
         await this.updateProductsInternal([productId]);
         return true;
         return true;
     }
     }
@@ -131,29 +130,29 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
      * Updates the search index only for the affected product.
      * Updates the search index only for the affected product.
      */
      */
     async removeProductFromChannel({
     async removeProductFromChannel({
-                                       ctx: rawContext,
-                                       productId,
-                                       channelId,
-                                   }: ProductChannelMessageData): Promise<boolean> {
+        ctx: rawContext,
+        productId,
+        channelId,
+    }: ProductChannelMessageData): Promise<boolean> {
         await this.updateProductsInternal([productId]);
         await this.updateProductsInternal([productId]);
         return true;
         return true;
     }
     }
 
 
     async assignVariantToChannel({
     async assignVariantToChannel({
-                                     ctx: rawContext,
-                                     productVariantId,
-                                     channelId,
-                                 }: VariantChannelMessageData): Promise<boolean> {
+        ctx: rawContext,
+        productVariantId,
+        channelId,
+    }: VariantChannelMessageData): Promise<boolean> {
         const productIds = await this.getProductIdsByVariantIds([productVariantId]);
         const productIds = await this.getProductIdsByVariantIds([productVariantId]);
         await this.updateProductsInternal(productIds);
         await this.updateProductsInternal(productIds);
         return true;
         return true;
     }
     }
 
 
     async removeVariantFromChannel({
     async removeVariantFromChannel({
-                                       ctx: rawContext,
-                                       productVariantId,
-                                       channelId,
-                                   }: VariantChannelMessageData): Promise<boolean> {
+        ctx: rawContext,
+        productVariantId,
+        channelId,
+    }: VariantChannelMessageData): Promise<boolean> {
         const productIds = await this.getProductIdsByVariantIds([productVariantId]);
         const productIds = await this.getProductIdsByVariantIds([productVariantId]);
         await this.updateProductsInternal(productIds);
         await this.updateProductsInternal(productIds);
         return true;
         return true;
@@ -179,9 +178,9 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
     }
     }
 
 
     updateVariantsById({
     updateVariantsById({
-                           ctx: rawContext,
-                           ids,
-                       }: UpdateVariantsByIdMessageData): Observable<ReindexMessageResponse> {
+        ctx: rawContext,
+        ids,
+    }: UpdateVariantsByIdMessageData): Observable<ReindexMessageResponse> {
         return asyncObservable(async observer => {
         return asyncObservable(async observer => {
             return this.asyncQueue.push(async () => {
             return this.asyncQueue.push(async () => {
                 const timeStart = Date.now();
                 const timeStart = Date.now();
@@ -216,15 +215,12 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
 
 
                 const reindexTempName = new Date().getTime();
                 const reindexTempName = new Date().getTime();
                 try {
                 try {
-
                     const getIndexNameByAlias = async (aliasName: string) => {
                     const getIndexNameByAlias = async (aliasName: string) => {
                         const aliasExist = await this.client.indices.existsAlias({ name: aliasName });
                         const aliasExist = await this.client.indices.existsAlias({ name: aliasName });
                         if (aliasExist.body) {
                         if (aliasExist.body) {
-                            const alias = await this.client.indices.getAlias(
-                                {
-                                    name: aliasName,
-                                },
-                            );
+                            const alias = await this.client.indices.getAlias({
+                                name: aliasName,
+                            });
                             return Object.keys(alias.body)[0];
                             return Object.keys(alias.body)[0];
                         } else {
                         } else {
                             return aliasName;
                             return aliasName;
@@ -240,18 +236,32 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                         true,
                         true,
                         `-reindex-${reindexTempName}`,
                         `-reindex-${reindexTempName}`,
                     );
                     );
-                    const reindexProductAliasName = this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`;
-                    const reindexVariantAliasName = this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`;
+                    const reindexProductAliasName =
+                        this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`;
+                    const reindexVariantAliasName =
+                        this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`;
                     const reindexProductIndexName = await getIndexNameByAlias(reindexProductAliasName);
                     const reindexProductIndexName = await getIndexNameByAlias(reindexProductAliasName);
                     const reindexVariantIndexName = await getIndexNameByAlias(reindexVariantAliasName);
                     const reindexVariantIndexName = await getIndexNameByAlias(reindexVariantAliasName);
 
 
-                    const originalProductAliasExist = await this.client.indices.existsAlias({ name: this.options.indexPrefix + PRODUCT_INDEX_NAME });
-                    const originalVariantAliasExist = await this.client.indices.existsAlias({ name: this.options.indexPrefix + VARIANT_INDEX_NAME });
-                    const originalProductIndexExist = await this.client.indices.exists({ index: this.options.indexPrefix + PRODUCT_INDEX_NAME });
-                    const originalVariantIndexExist = await this.client.indices.exists({ index: this.options.indexPrefix + PRODUCT_INDEX_NAME });
+                    const originalProductAliasExist = await this.client.indices.existsAlias({
+                        name: this.options.indexPrefix + PRODUCT_INDEX_NAME,
+                    });
+                    const originalVariantAliasExist = await this.client.indices.existsAlias({
+                        name: this.options.indexPrefix + VARIANT_INDEX_NAME,
+                    });
+                    const originalProductIndexExist = await this.client.indices.exists({
+                        index: this.options.indexPrefix + PRODUCT_INDEX_NAME,
+                    });
+                    const originalVariantIndexExist = await this.client.indices.exists({
+                        index: this.options.indexPrefix + PRODUCT_INDEX_NAME,
+                    });
 
 
-                    const originalProductIndexName = await getIndexNameByAlias(this.options.indexPrefix + PRODUCT_INDEX_NAME);
-                    const originalVariantIndexName = await getIndexNameByAlias(this.options.indexPrefix + VARIANT_INDEX_NAME);
+                    const originalProductIndexName = await getIndexNameByAlias(
+                        this.options.indexPrefix + PRODUCT_INDEX_NAME,
+                    );
+                    const originalVariantIndexName = await getIndexNameByAlias(
+                        this.options.indexPrefix + VARIANT_INDEX_NAME,
+                    );
 
 
                     if (originalVariantAliasExist.body || originalVariantIndexExist.body) {
                     if (originalVariantAliasExist.body || originalVariantIndexExist.body) {
                         await this.client.reindex({
                         await this.client.reindex({
@@ -261,7 +271,10 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                                     index: this.options.indexPrefix + VARIANT_INDEX_NAME,
                                     index: this.options.indexPrefix + VARIANT_INDEX_NAME,
                                 },
                                 },
                                 dest: {
                                 dest: {
-                                    index: this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                                    index:
+                                        this.options.indexPrefix +
+                                        VARIANT_INDEX_NAME +
+                                        `-reindex-${reindexTempName}`,
                                 },
                                 },
                             },
                             },
                         });
                         });
@@ -274,7 +287,10 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                                     index: this.options.indexPrefix + PRODUCT_INDEX_NAME,
                                     index: this.options.indexPrefix + PRODUCT_INDEX_NAME,
                                 },
                                 },
                                 dest: {
                                 dest: {
-                                    index: this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                                    index:
+                                        this.options.indexPrefix +
+                                        PRODUCT_INDEX_NAME +
+                                        `-reindex-${reindexTempName}`,
                                 },
                                 },
                             },
                             },
                         });
                         });
@@ -284,13 +300,19 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                         {
                         {
                             remove: {
                             remove: {
                                 index: reindexVariantIndexName,
                                 index: reindexVariantIndexName,
-                                alias: this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                                alias:
+                                    this.options.indexPrefix +
+                                    VARIANT_INDEX_NAME +
+                                    `-reindex-${reindexTempName}`,
                             },
                             },
                         },
                         },
                         {
                         {
                             remove: {
                             remove: {
                                 index: reindexProductIndexName,
                                 index: reindexProductIndexName,
-                                alias: this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                                alias:
+                                    this.options.indexPrefix +
+                                    PRODUCT_INDEX_NAME +
+                                    `-reindex-${reindexTempName}`,
                             },
                             },
                         },
                         },
                         {
                         {
@@ -309,12 +331,11 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
 
 
                     if (originalProductAliasExist.body) {
                     if (originalProductAliasExist.body) {
                         actions.push({
                         actions.push({
-                                remove: {
-                                    index: originalProductIndexName,
-                                    alias: this.options.indexPrefix + PRODUCT_INDEX_NAME,
-                                },
+                            remove: {
+                                index: originalProductIndexName,
+                                alias: this.options.indexPrefix + PRODUCT_INDEX_NAME,
                             },
                             },
-                        );
+                        });
                     } else if (originalProductIndexExist.body) {
                     } else if (originalProductIndexExist.body) {
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [this.options.indexPrefix + PRODUCT_INDEX_NAME],
                             index: [this.options.indexPrefix + PRODUCT_INDEX_NAME],
@@ -323,12 +344,11 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
 
 
                     if (originalVariantAliasExist.body) {
                     if (originalVariantAliasExist.body) {
                         actions.push({
                         actions.push({
-                                remove: {
-                                    index: originalVariantIndexName,
-                                    alias: this.options.indexPrefix + VARIANT_INDEX_NAME,
-                                },
+                            remove: {
+                                index: originalVariantIndexName,
+                                alias: this.options.indexPrefix + VARIANT_INDEX_NAME,
                             },
                             },
-                        );
+                        });
                     } else if (originalVariantIndexExist.body) {
                     } else if (originalVariantIndexExist.body) {
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [this.options.indexPrefix + VARIANT_INDEX_NAME],
                             index: [this.options.indexPrefix + VARIANT_INDEX_NAME],
@@ -341,41 +361,44 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                         },
                         },
                     });
                     });
 
 
-                    if (originalProductAliasExist.body)
-                    {
+                    if (originalProductAliasExist.body) {
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [originalProductIndexName],
                             index: [originalProductIndexName],
                         });
                         });
                     }
                     }
-                    if (originalVariantAliasExist.body)
-                    {
+                    if (originalVariantAliasExist.body) {
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [originalVariantIndexName],
                             index: [originalVariantIndexName],
                         });
                         });
                     }
                     }
                 } catch (e) {
                 } catch (e) {
-                    Logger.warn(`Could not recreate indices. Reindexing continue with existing indices.`, loggerCtx);
+                    Logger.warn(
+                        `Could not recreate indices. Reindexing continue with existing indices.`,
+                        loggerCtx,
+                    );
                     Logger.warn(JSON.stringify(e), loggerCtx);
                     Logger.warn(JSON.stringify(e), loggerCtx);
                 } finally {
                 } finally {
-                    const reindexVariantAliasExist = await this.client.indices.existsAlias({ name: this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}` });
+                    const reindexVariantAliasExist = await this.client.indices.existsAlias({
+                        name: this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                    });
                     if (reindexVariantAliasExist.body) {
                     if (reindexVariantAliasExist.body) {
-                        const reindexVariantAliasResult = await this.client.indices.getAlias(
-                            {
-                                name: this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`,
-                            },
-                        );
+                        const reindexVariantAliasResult = await this.client.indices.getAlias({
+                            name:
+                                this.options.indexPrefix + VARIANT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                        });
                         const reindexVariantIndexName = Object.keys(reindexVariantAliasResult.body)[0];
                         const reindexVariantIndexName = Object.keys(reindexVariantAliasResult.body)[0];
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [reindexVariantIndexName],
                             index: [reindexVariantIndexName],
                         });
                         });
                     }
                     }
-                    const reindexProductAliasExist = await this.client.indices.existsAlias({ name: this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}` });
+                    const reindexProductAliasExist = await this.client.indices.existsAlias({
+                        name: this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                    });
                     if (reindexProductAliasExist.body) {
                     if (reindexProductAliasExist.body) {
-                        const reindexProductAliasResult = await this.client.indices.getAlias(
-                            {
-                                name: this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`,
-                            },
-                        );
+                        const reindexProductAliasResult = await this.client.indices.getAlias({
+                            name:
+                                this.options.indexPrefix + PRODUCT_INDEX_NAME + `-reindex-${reindexTempName}`,
+                        });
                         const reindexProductIndexName = Object.keys(reindexProductAliasResult.body)[0];
                         const reindexProductIndexName = Object.keys(reindexProductAliasResult.body)[0];
                         await this.client.indices.delete({
                         await this.client.indices.delete({
                             index: [reindexProductIndexName],
                             index: [reindexProductIndexName],
@@ -585,15 +608,15 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                                 operation: {
                                 operation: {
                                     doc: variantsInChannel.length
                                     doc: variantsInChannel.length
                                         ? this.createProductIndexItem(
                                         ? this.createProductIndexItem(
-                                            variantsInChannel,
-                                            channelCtx.channelId,
-                                            languageCode,
-                                        )
+                                              variantsInChannel,
+                                              channelCtx.channelId,
+                                              languageCode,
+                                          )
                                         : this.createSyntheticProductIndexItem(
                                         : this.createSyntheticProductIndexItem(
-                                            channelCtx,
-                                            product,
-                                            languageCode,
-                                        ),
+                                              channelCtx,
+                                              product,
+                                              languageCode,
+                                          ),
                                     doc_as_upsert: true,
                                     doc_as_upsert: true,
                                 },
                                 },
                             },
                             },

+ 13 - 6
packages/elasticsearch-plugin/src/indexing-utils.ts

@@ -4,8 +4,15 @@ import { ID, Logger } from '@vendure/core';
 import { loggerCtx, PRODUCT_INDEX_NAME, VARIANT_INDEX_NAME } from './constants';
 import { loggerCtx, PRODUCT_INDEX_NAME, VARIANT_INDEX_NAME } from './constants';
 import { ProductIndexItem, VariantIndexItem } from './types';
 import { ProductIndexItem, VariantIndexItem } from './types';
 
 
-export async function createIndices(client: Client, prefix: string, indexSettings: object, indexMappingProperties: object,
-                                    primaryKeyType: 'increment' | 'uuid', mapAlias = true, aliasPostfix = ``) {
+export async function createIndices(
+    client: Client,
+    prefix: string,
+    indexSettings: object,
+    indexMappingProperties: object,
+    primaryKeyType: 'increment' | 'uuid',
+    mapAlias = true,
+    aliasPostfix = ``,
+) {
     const textWithKeyword = {
     const textWithKeyword = {
         type: 'text',
         type: 'text',
         fields: {
         fields: {
@@ -59,7 +66,7 @@ export async function createIndices(client: Client, prefix: string, indexSetting
 
 
     const unixtimestampPostfix = new Date().getTime();
     const unixtimestampPostfix = new Date().getTime();
 
 
-    const createIndex = async (mappings:{ [prop in keyof any]: any }, index: string, alias: string) => {
+    const createIndex = async (mappings: { [prop in keyof any]: any }, index: string, alias: string) => {
         if (mapAlias) {
         if (mapAlias) {
             await client.indices.create({
             await client.indices.create({
                 index,
                 index,
@@ -87,13 +94,13 @@ export async function createIndices(client: Client, prefix: string, indexSetting
             });
             });
             Logger.verbose(`Created index "${alias}"`, loggerCtx);
             Logger.verbose(`Created index "${alias}"`, loggerCtx);
         }
         }
-    }
+    };
 
 
     try {
     try {
         const index = prefix + VARIANT_INDEX_NAME + `${unixtimestampPostfix}`;
         const index = prefix + VARIANT_INDEX_NAME + `${unixtimestampPostfix}`;
         const alias = prefix + VARIANT_INDEX_NAME + aliasPostfix;
         const alias = prefix + VARIANT_INDEX_NAME + aliasPostfix;
 
 
-        await createIndex(variantMappings, index,alias);
+        await createIndex(variantMappings, index, alias);
     } catch (e) {
     } catch (e) {
         Logger.error(JSON.stringify(e, null, 2), loggerCtx);
         Logger.error(JSON.stringify(e, null, 2), loggerCtx);
     }
     }
@@ -102,7 +109,7 @@ export async function createIndices(client: Client, prefix: string, indexSetting
         const index = prefix + PRODUCT_INDEX_NAME + `${unixtimestampPostfix}`;
         const index = prefix + PRODUCT_INDEX_NAME + `${unixtimestampPostfix}`;
         const alias = prefix + PRODUCT_INDEX_NAME + aliasPostfix;
         const alias = prefix + PRODUCT_INDEX_NAME + aliasPostfix;
 
 
-        await createIndex(productMappings, index,alias);
+        await createIndex(productMappings, index, alias);
     } catch (e) {
     } catch (e) {
         Logger.error(JSON.stringify(e, null, 2), loggerCtx);
         Logger.error(JSON.stringify(e, null, 2), loggerCtx);
     }
     }

+ 2 - 2
packages/elasticsearch-plugin/src/options.ts

@@ -203,7 +203,7 @@ export interface SearchConfig {
      * @default
      * @default
      * 10000
      * 10000
      */
      */
-    totalItemsMaxSize?: number|boolean;
+    totalItemsMaxSize?: number | boolean;
 
 
     // prettier-ignore
     // prettier-ignore
     /**
     /**
@@ -355,7 +355,7 @@ export const defaultOptions: ElasticsearchRuntimeOptions = {
     connectionAttemptInterval: 5000,
     connectionAttemptInterval: 5000,
     indexPrefix: 'vendure-',
     indexPrefix: 'vendure-',
     indexSettings: {},
     indexSettings: {},
-    indexMappingProperties:{},
+    indexMappingProperties: {},
     batchSize: 2000,
     batchSize: 2000,
     searchConfig: {
     searchConfig: {
         facetValueMaxSize: 50,
         facetValueMaxSize: 50,

+ 1 - 1
packages/elasticsearch-plugin/src/types.ts

@@ -90,7 +90,7 @@ export type SearchRequestBody = {
     sort?: any[];
     sort?: any[];
     from?: number;
     from?: number;
     size?: number;
     size?: number;
-    track_total_hits?: number|boolean,
+    track_total_hits?: number | boolean;
     aggs?: any;
     aggs?: any;
 };
 };