Skip to content

Commit

Permalink
changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jul 2, 2020
1 parent ad6b84d commit ec91ce6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 4 additions & 12 deletions x-pack/plugins/ml/server/routes/schemas/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,11 @@ export const setupModuleBodySchema = schema.object({
estimateModelMemory: schema.maybe(schema.boolean()),
});

export const getModuleIdParamSchema = (optional = false) => {
const stringType = schema.string();
return schema.object({
/**
* ID of the module.
*/
moduleId: optional ? schema.maybe(stringType) : stringType,
});
};

export const optionalModuleIdParamSchema = getModuleIdParamSchema(true);
export const optionalModuleIdParamSchema = schema.object({
moduleId: schema.maybe(schema.string()),
});

export const moduleIdParamSchema = getModuleIdParamSchema(false);
export const moduleIdParamSchema = schema.object({ moduleId: schema.string() });

export const modulesIndexPatternTitleSchema = schema.object({
/**
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/ml/server/shared_services/providers/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { LegacyAPICaller, KibanaRequest, SavedObjectsClientContract } from 'kiba
import { TypeOf } from '@kbn/config-schema';
import { DataRecognizer } from '../../models/data_recognizer';
import { SharedServicesChecks } from '../shared_services';
import { setupModuleBodySchema } from '../../routes/schemas/modules';
import { moduleIdParamSchema, setupModuleBodySchema } from '../../routes/schemas/modules';

export type ModuleSetupPayload = { moduleId: string } & TypeOf<typeof setupModuleBodySchema>;
export type ModuleSetupPayload = TypeOf<typeof moduleIdParamSchema> &
TypeOf<typeof setupModuleBodySchema>;

export interface ModulesProvider {
modulesProvider(
Expand Down

0 comments on commit ec91ce6

Please sign in to comment.