mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[data views] reduce any
usage on server side service (#112750)
* remove some any instances from data view
This commit is contained in:
parent
548944e6d3
commit
7ecae91e64
6 changed files with 13 additions and 12 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
import _, { each, reject } from 'lodash';
|
||||
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '../..';
|
||||
import type { RuntimeField } from '../types';
|
||||
import { DuplicateField } from '../../../../kibana_utils/common';
|
||||
|
@ -158,7 +159,7 @@ export class DataView implements IIndexPattern {
|
|||
};
|
||||
|
||||
getComputedFields() {
|
||||
const scriptFields: Record<string, { script: { source: string; lang: string } }> = {};
|
||||
const scriptFields: Record<string, estypes.ScriptField> = {};
|
||||
if (!this.fields) {
|
||||
return {
|
||||
storedFields: ['*'],
|
||||
|
@ -185,7 +186,7 @@ export class DataView implements IIndexPattern {
|
|||
scriptFields[field.name] = {
|
||||
script: {
|
||||
source: field.script as string,
|
||||
lang: field.lang as string,
|
||||
lang: field.lang,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -89,8 +89,8 @@ export type OnNotification = (toastInputFields: ToastInputFields) => void;
|
|||
export type OnError = (error: Error, toastInputFields: ErrorToastOptions) => void;
|
||||
|
||||
export interface UiSettingsCommon {
|
||||
get: (key: string) => Promise<any>;
|
||||
getAll: () => Promise<Record<string, any>>;
|
||||
get: <T = any>(key: string) => Promise<T>;
|
||||
getAll: () => Promise<Record<string, unknown>>;
|
||||
set: (key: string, value: any) => Promise<void>;
|
||||
remove: (key: string) => Promise<void>;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IUiSettingsClient } from 'src/core/public';
|
||||
import { IUiSettingsClient, PublicUiSettingsParams, UserProvidedValues } from 'src/core/public';
|
||||
import { UiSettingsCommon } from '../../common';
|
||||
|
||||
export class UiSettingsPublicToCommon implements UiSettingsCommon {
|
||||
|
@ -14,11 +14,11 @@ export class UiSettingsPublicToCommon implements UiSettingsCommon {
|
|||
constructor(uiSettings: IUiSettingsClient) {
|
||||
this.uiSettings = uiSettings;
|
||||
}
|
||||
get(key: string) {
|
||||
get<T = any>(key: string): Promise<T> {
|
||||
return Promise.resolve(this.uiSettings.get(key));
|
||||
}
|
||||
|
||||
getAll() {
|
||||
getAll<T = any>(): Promise<Record<string, PublicUiSettingsParams & UserProvidedValues<T>>> {
|
||||
return Promise.resolve(this.uiSettings.getAll());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { HttpServiceSetup, RequestHandlerContext, StartServicesAccessor } from 'kibana/server';
|
||||
import { HttpServiceSetup, StartServicesAccessor } from 'kibana/server';
|
||||
import { IndexPatternsFetcher } from './fetcher';
|
||||
import { registerCreateIndexPatternRoute } from './routes/create_index_pattern';
|
||||
import { registerGetIndexPatternRoute } from './routes/get_index_pattern';
|
||||
|
@ -154,7 +154,7 @@ export function registerRoutes(
|
|||
}),
|
||||
},
|
||||
},
|
||||
async (context: RequestHandlerContext, request: any, response: any) => {
|
||||
async (context, request, response) => {
|
||||
const { asCurrentUser } = context.core.elasticsearch.client;
|
||||
const indexPatterns = new IndexPatternsFetcher(asCurrentUser);
|
||||
const { pattern, interval, look_back: lookBack, meta_fields: metaFields } = request.query;
|
||||
|
|
|
@ -14,11 +14,11 @@ export class UiSettingsServerToCommon implements UiSettingsCommon {
|
|||
constructor(uiSettings: IUiSettingsClient) {
|
||||
this.uiSettings = uiSettings;
|
||||
}
|
||||
get(key: string) {
|
||||
get<T = any>(key: string): Promise<T> {
|
||||
return this.uiSettings.get(key);
|
||||
}
|
||||
|
||||
getAll() {
|
||||
getAll<T = any>(): Promise<Record<string, T>> {
|
||||
return this.uiSettings.getAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ export function buildSearchBody(
|
|||
},
|
||||
},
|
||||
stored_fields: computedFields.storedFields,
|
||||
script_fields: computedFields.scriptFields as Record<string, estypes.ScriptField>,
|
||||
script_fields: computedFields.scriptFields,
|
||||
version: true,
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue