Skip to content

Commit

Permalink
rename types for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Oct 3, 2021
1 parent 803e818 commit 6d7d848
Show file tree
Hide file tree
Showing 30 changed files with 193 additions and 97 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ pageLoadAssetSize:
expressions: 239290
securitySolution: 231753
customIntegrations: 28810
dataViews: 100000
dataViews: 42000
5 changes: 2 additions & 3 deletions src/plugins/data/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { CoreStart } from 'src/core/public';
import { BfetchPublicSetup } from 'src/plugins/bfetch/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
// todo rename this
import { DataViewPublicPluginStart } from 'src/plugins/data_views/public';
import { DataViewsPublicPluginStart } from 'src/plugins/data_views/public';
import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
Expand All @@ -37,7 +36,7 @@ export interface DataSetupDependencies {
export interface DataStartDependencies {
uiActions: UiActionsStart;
fieldFormats: FieldFormatsStart;
dataViews: DataViewPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/data/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { BfetchServerSetup } from 'src/plugins/bfetch/server';
// todo rename this
import { IndexPatternsServiceStart } from 'src/plugins/data_views/server';
import { PluginStart as DataViewsServerPluginStart } from 'src/plugins/data_views/server';
import { ConfigSchema } from '../config';
import { ISearchSetup, ISearchStart, SearchEnhancements } from './search';
import { SearchService } from './search/search_service';
Expand Down Expand Up @@ -44,7 +43,7 @@ export interface DataPluginStart {
* @deprecated - use "fieldFormats" plugin directly instead
*/
fieldFormats: FieldFormatsStart;
indexPatterns: IndexPatternsServiceStart;
indexPatterns: DataViewsServerPluginStart;
}

export interface DataPluginSetupDependencies {
Expand All @@ -57,7 +56,7 @@ export interface DataPluginSetupDependencies {
export interface DataPluginStartDependencies {
fieldFormats: FieldFormatsStart;
logger: Logger;
dataViews: IndexPatternsServiceStart;
dataViews: DataViewsServerPluginStart;
}

export class DataServerPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
IndexPatternLoadExpressionFunctionDefinition,
IndexPatternLoadStartDependencies,
} from '../../common/expressions';
import { DataViewPublicPluginStart, DataViewStartDependencies } from '../types';
import { DataViewsPublicPluginStart, DataViewsPublicStartDependencies } from '../types';

/**
* Returns the expression function definition. Any stateful dependencies are accessed
Expand Down Expand Up @@ -60,7 +60,10 @@ export function getFunctionDefinition({
export function getIndexPatternLoad({
getStartServices,
}: {
getStartServices: StartServicesAccessor<DataViewStartDependencies, DataViewPublicPluginStart>;
getStartServices: StartServicesAccessor<
DataViewsPublicStartDependencies,
DataViewsPublicPluginStart
>;
}) {
return getFunctionDefinition({
getStartDependencies: async () => {
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/data_views/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper
* Plugin setup
*/

import { DataViewPublicPlugin } from './plugin';
import { DataViewsPublicPlugin } from './plugin';

export function plugin() {
return new DataViewPublicPlugin();
return new DataViewsPublicPlugin();
}

export type { DataViewPublicPluginSetup, DataViewPublicPluginStart } from './types';
export type { DataViewsPublicPluginSetup, DataViewsPublicPluginStart } from './types';

// Export plugin after all other imports
export type { DataViewPublicPlugin as DataPlugin };
export type { DataViewsPublicPlugin as DataPlugin };
29 changes: 14 additions & 15 deletions src/plugins/data_views/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { getIndexPatternLoad } from './expressions';
import {
DataViewPublicPluginSetup,
DataViewPublicPluginStart,
DataViewSetupDependencies,
DataViewStartDependencies,
DataViewsPublicPluginSetup,
DataViewsPublicPluginStart,
DataViewsPublicSetupDependencies,
DataViewsPublicStartDependencies,
} from './types';

import {
Expand All @@ -23,29 +23,28 @@ import {
SavedObjectsClientPublicToCommon,
} from '.';

// todo review file
export class DataViewPublicPlugin
export class DataViewsPublicPlugin
implements
Plugin<
DataViewPublicPluginSetup,
DataViewPublicPluginStart,
DataViewSetupDependencies,
DataViewStartDependencies
DataViewsPublicPluginSetup,
DataViewsPublicPluginStart,
DataViewsPublicSetupDependencies,
DataViewsPublicStartDependencies
>
{
public setup(
core: CoreSetup<DataViewStartDependencies, DataViewPublicPluginStart>,
{ expressions }: DataViewSetupDependencies
): DataViewPublicPluginSetup {
core: CoreSetup<DataViewsPublicStartDependencies, DataViewsPublicPluginStart>,
{ expressions }: DataViewsPublicSetupDependencies
): DataViewsPublicPluginSetup {
expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));

return {};
}

public start(
core: CoreStart,
{ fieldFormats }: DataViewStartDependencies
): DataViewPublicPluginStart {
{ fieldFormats }: DataViewsPublicStartDependencies
): DataViewsPublicPluginStart {
const { uiSettings, http, notifications, savedObjects, overlays, application } = core;

return new DataViewsService({
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/data_views/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/
import { PublicMethodsOf } from '@kbn/utility-types';
import { DataViewsService } from './data_views';

export interface DataViewSetupDependencies {
export interface DataViewsPublicSetupDependencies {
expressions: ExpressionsSetup;
fieldFormats: FieldFormatsSetup;
}

export interface DataViewStartDependencies {
export interface DataViewsPublicStartDependencies {
fieldFormats: FieldFormatsStart;
}

/**
* Data plugin public Setup contract
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataViewPublicPluginSetup {}
export interface DataViewsPublicPluginSetup {}

/**
* Data plugin public Start contract
*/
export type DataViewPublicPluginStart = PublicMethodsOf<DataViewsService>;
export type DataViewsPublicPluginStart = PublicMethodsOf<DataViewsService>;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IndexPatternLoadExpressionFunctionDefinition,
IndexPatternLoadStartDependencies,
} from '../../common/expressions';
import { DataViewPluginStartDependencies, DataViewPluginStart } from '../types';
import { DataViewsServerPluginStartDependencies, DataViewsServerPluginStart } from '../types';

/**
* Returns the expression function definition. Any stateful dependencies are accessed
Expand Down Expand Up @@ -73,7 +73,10 @@ export function getFunctionDefinition({
export function getIndexPatternLoad({
getStartServices,
}: {
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>;
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>;
}) {
return getFunctionDefinition({
getStartDependencies: async (request: KibanaRequest) => {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/data_views/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export {
export { IndexPatternsServiceStart } from './types';

import { PluginInitializerContext } from 'src/core/server';
import { DataViewServerPlugin } from './plugin';
import { DataViewPluginSetup, DataViewPluginStart } from './types';
import { DataViewsServerPlugin } from './plugin';
import { DataViewsServerPluginSetup, DataViewsServerPluginStart } from './types';
export type { dataViewsServiceFactory } from './data_views_service_factory';

/**
Expand All @@ -27,11 +27,11 @@ export type { dataViewsServiceFactory } from './data_views_service_factory';
*/

export function plugin(initializerContext: PluginInitializerContext) {
return new DataViewServerPlugin(initializerContext);
return new DataViewsServerPlugin(initializerContext);
}

export {
DataViewServerPlugin as Plugin,
DataViewPluginSetup as PluginSetup,
DataViewPluginStart as PluginStart,
DataViewsServerPlugin as Plugin,
DataViewsServerPluginSetup as PluginSetup,
DataViewsServerPluginStart as PluginStart,
};
29 changes: 16 additions & 13 deletions src/plugins/data_views/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import { getIndexPatternLoad } from './expressions';
import { registerIndexPatternsUsageCollector } from './register_index_pattern_usage_collection';
import { createScriptedFieldsDeprecationsConfig } from './deprecations';
import {
DataViewPluginSetup,
DataViewPluginStart,
DataViewPluginSetupDependencies,
DataViewPluginStartDependencies,
DataViewsServerPluginSetup,
DataViewsServerPluginStart,
DataViewsServerPluginSetupDependencies,
DataViewsServerPluginStartDependencies,
} from './types';

export class DataViewServerPlugin
export class DataViewsServerPlugin
implements
Plugin<
DataViewPluginSetup,
DataViewPluginStart,
DataViewPluginSetupDependencies,
DataViewPluginStartDependencies
DataViewsServerPluginSetup,
DataViewsServerPluginStart,
DataViewsServerPluginSetupDependencies,
DataViewsServerPluginStartDependencies
>
{
private readonly logger: Logger;
Expand All @@ -37,8 +37,8 @@ export class DataViewServerPlugin
}

public setup(
core: CoreSetup<DataViewPluginStartDependencies, DataViewPluginStart>,
{ expressions, usageCollection }: DataViewPluginSetupDependencies
core: CoreSetup<DataViewsServerPluginStartDependencies, DataViewsServerPluginStart>,
{ expressions, usageCollection }: DataViewsServerPluginSetupDependencies
) {
core.savedObjects.registerType(dataViewSavedObjectType);
core.capabilities.registerProvider(capabilitiesProvider);
Expand All @@ -52,7 +52,10 @@ export class DataViewServerPlugin
return {};
}

public start({ uiSettings }: CoreStart, { fieldFormats }: DataViewPluginStartDependencies) {
public start(
{ uiSettings }: CoreStart,
{ fieldFormats }: DataViewsServerPluginStartDependencies
) {
const serviceFactory = dataViewsServiceFactory({
logger: this.logger.get('indexPatterns'),
uiSettings,
Expand All @@ -68,4 +71,4 @@ export class DataViewServerPlugin
public stop() {}
}

export { DataViewServerPlugin as Plugin };
export { DataViewsServerPlugin as Plugin };
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { StartServicesAccessor } from 'src/core/server';
import { DataViewsService } from '../common';
import { SavedObjectsClient } from '../../../core/server';
import { DataViewPluginStartDependencies, DataViewPluginStart } from './types';
import { DataViewsServerPluginStartDependencies, DataViewsServerPluginStart } from './types';

interface CountSummary {
min?: number;
Expand Down Expand Up @@ -139,7 +139,10 @@ export async function getIndexPatternTelemetry(indexPatterns: DataViewsService)
}

export function registerIndexPatternsUsageCollector(
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>,
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>,
usageCollection?: UsageCollectionSetup
): void {
if (!usageCollection) {
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data_views/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { registerPutScriptedFieldRoute } from './routes/scripted_fields/put_scri
import { registerGetScriptedFieldRoute } from './routes/scripted_fields/get_scripted_field';
import { registerDeleteScriptedFieldRoute } from './routes/scripted_fields/delete_scripted_field';
import { registerUpdateScriptedFieldRoute } from './routes/scripted_fields/update_scripted_field';
import type { DataViewPluginStart, DataViewPluginStartDependencies } from './types';
import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from './types';
import { registerManageDefaultIndexPatternRoutes } from './routes/default_index_pattern';
import { registerCreateRuntimeFieldRoute } from './routes/runtime_fields/create_runtime_field';
import { registerGetRuntimeFieldRoute } from './routes/runtime_fields/get_runtime_field';
Expand All @@ -30,7 +30,10 @@ import { registerHasUserIndexPatternRoute } from './routes/has_user_index_patter

export function registerRoutes(
http: HttpServiceSetup,
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>
) {
const parseMetaFields = (metaFields: string | string[]) => {
let parsedFields: string[] = [];
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data_views/server/routes/create_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
serializedFieldFormatSchema,
} from './util/schemas';
import { IRouter, StartServicesAccessor } from '../../../../core/server';
import type { DataViewPluginStart, DataViewPluginStartDependencies } from '../types';
import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';

const indexPatternSpecSchema = schema.object({
title: schema.string(),
Expand Down Expand Up @@ -48,7 +48,10 @@ const indexPatternSpecSchema = schema.object({

export const registerCreateIndexPatternRoute = (
router: IRouter,
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>
) => {
router.post(
{
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data_views/server/routes/default_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

import { schema } from '@kbn/config-schema';
import { IRouter, StartServicesAccessor } from '../../../../core/server';
import type { DataViewPluginStart, DataViewPluginStartDependencies } from '../types';
import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
import { handleErrors } from './util/handle_errors';

export const registerManageDefaultIndexPatternRoutes = (
router: IRouter,
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>
) => {
router.get(
{
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data_views/server/routes/delete_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from './util/handle_errors';
import { IRouter, StartServicesAccessor } from '../../../../core/server';
import type { DataViewPluginStart, DataViewPluginStartDependencies } from '../types';
import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';

export const registerDeleteIndexPatternRoute = (
router: IRouter,
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>
) => {
router.delete(
{
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/data_views/server/routes/fields/update_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { serializedFieldFormatSchema } from '../util/schemas';
import { IRouter, StartServicesAccessor } from '../../../../../core/server';
import type { DataViewPluginStart, DataViewPluginStartDependencies } from '../../types';
import type {
DataViewsServerPluginStart,
DataViewsServerPluginStartDependencies,
} from '../../types';

export const registerUpdateFieldsRoute = (
router: IRouter,
getStartServices: StartServicesAccessor<DataViewPluginStartDependencies, DataViewPluginStart>
getStartServices: StartServicesAccessor<
DataViewsServerPluginStartDependencies,
DataViewsServerPluginStart
>
) => {
router.post(
{
Expand Down
Loading

0 comments on commit 6d7d848

Please sign in to comment.