Преглед изворни кода

Rename type guard functions for Elasticsearch client delegators to improve clarity

Shun Miyazawa пре 9 месеци
родитељ
комит
5fa9a6b91e

+ 3 - 3
apps/app/src/server/service/search-delegator/elasticsearch-client-delegator/interfaces.ts

@@ -6,15 +6,15 @@ export type ElasticsearchClientDelegator = ES7ClientDelegator | ES8ClientDelegat
 
 
 
 
 // type guard
 // type guard
-export const isES7Client = (delegator: ElasticsearchClientDelegator): delegator is ES7ClientDelegator => {
+export const isES7ClientDelegetor = (delegator: ElasticsearchClientDelegator): delegator is ES7ClientDelegator => {
   return delegator.delegetorVersion === 7;
   return delegator.delegetorVersion === 7;
 };
 };
 
 
-export const isES8Client = (delegator: ElasticsearchClientDelegator): delegator is ES8ClientDelegator => {
+export const isES8ClientDelegetor = (delegator: ElasticsearchClientDelegator): delegator is ES8ClientDelegator => {
   return delegator.delegetorVersion === 8;
   return delegator.delegetorVersion === 8;
 };
 };
 
 
 // TODO: https://redmine.weseek.co.jp/issues/168446
 // TODO: https://redmine.weseek.co.jp/issues/168446
-export const isES9Client = (delegator: ElasticsearchClientDelegator): delegator is ES9ClientDelegator => {
+export const isES9ClientDelegetor = (delegator: ElasticsearchClientDelegator): delegator is ES9ClientDelegator => {
   return delegator.delegetorVersion === 9;
   return delegator.delegetorVersion === 9;
 };
 };

+ 4 - 4
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -25,7 +25,7 @@ import type { UpdateOrInsertPagesOpts } from '../interfaces/search';
 import { aggregatePipelineToIndex } from './aggregate-to-index';
 import { aggregatePipelineToIndex } from './aggregate-to-index';
 import type { AggregatedPage, BulkWriteBody, BulkWriteCommand } from './bulk-write';
 import type { AggregatedPage, BulkWriteBody, BulkWriteCommand } from './bulk-write';
 import {
 import {
-  getClient, type ElasticsearchClientDelegator, isES9Client, isES7Client, isES8Client,
+  getClient, type ElasticsearchClientDelegator, isES9ClientDelegetor, isES7ClientDelegetor, isES8ClientDelegetor,
 } from './elasticsearch-client-delegator';
 } from './elasticsearch-client-delegator';
 
 
 const logger = loggerFactory('growi:service:search-delegator:elasticsearch');
 const logger = loggerFactory('growi:service:search-delegator:elasticsearch');
@@ -318,7 +318,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
 
   async createIndex(index: string) {
   async createIndex(index: string) {
     // TODO: https://redmine.weseek.co.jp/issues/168446
     // TODO: https://redmine.weseek.co.jp/issues/168446
-    if (isES7Client(this.client)) {
+    if (isES7ClientDelegetor(this.client)) {
       const { mappings } = await import('^/resource/search/mappings-es7');
       const { mappings } = await import('^/resource/search/mappings-es7');
       return this.client.indices.create({
       return this.client.indices.create({
         index,
         index,
@@ -328,7 +328,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
       });
       });
     }
     }
 
 
-    if (isES8Client(this.client)) {
+    if (isES8ClientDelegetor(this.client)) {
       const { mappings } = await import('^/resource/search/mappings-es8');
       const { mappings } = await import('^/resource/search/mappings-es8');
       return this.client.indices.create({
       return this.client.indices.create({
         index,
         index,
@@ -336,7 +336,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
       });
       });
     }
     }
 
 
-    if (isES9Client(this.client)) {
+    if (isES9ClientDelegetor(this.client)) {
       const { mappings } = process.env.CI == null
       const { mappings } = process.env.CI == null
         ? await import('^/resource/search/mappings-es9')
         ? await import('^/resource/search/mappings-es9')
         : await import('^/resource/search/mappings-es9-for-ci');
         : await import('^/resource/search/mappings-es9-for-ci');