Skip to content

Commit

Permalink
feat(rca): refactor item registry and manage items using api (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
kdelemme authored Aug 28, 2024
1 parent 0cc275a commit a570d94
Show file tree
Hide file tree
Showing 49 changed files with 654 additions and 1,158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
*/

import * as t from 'io-ts';
import { investigationItemsSchema } from '../schema';
import { itemSchema } from '../schema';
import { investigationItemResponseSchema } from './investigation_item';

const createInvestigationItemParamsSchema = t.type({
path: t.type({
investigationId: t.string,
}),
body: investigationItemsSchema,
body: itemSchema,
});

const createInvestigationItemResponseSchema = investigationItemResponseSchema;
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-investigation-shared/src/rest_specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type * from './investigation_note';
export type * from './create_item';
export type * from './delete_item';
export type * from './get_items';
export type * from './investigation_item';

export * from './create';
export * from './create_note';
Expand All @@ -29,3 +30,4 @@ export * from './investigation_note';
export * from './create_item';
export * from './delete_item';
export * from './get_items';
export * from './investigation_item';
25 changes: 14 additions & 11 deletions packages/kbn-investigation-shared/src/schema/investigation_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

import * as t from 'io-ts';

const esqlItemSchema = t.type({
const itemSchema = t.type({
title: t.string,
type: t.literal('esql'),
params: t.type({
esql: t.string,
suggestion: t.any,
}),
type: t.string,
params: t.record(t.string, t.any),
});

const investigationItemsSchema = esqlItemSchema; // replace with union with various item types

const investigationItemSchema = t.intersection([
t.type({ id: t.string, createdAt: t.number, createdBy: t.string }),
investigationItemsSchema,
t.type({
id: t.string,
createdAt: t.number,
createdBy: t.string,
}),
itemSchema,
]);

export { investigationItemSchema, investigationItemsSchema, esqlItemSchema };
type Item = t.TypeOf<typeof itemSchema>;
type InvestigationItem = t.TypeOf<typeof investigationItemSchema>;

export type { Item, InvestigationItem };
export { investigationItemSchema, itemSchema };
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export type {
Investigation,
InvestigateWidget,
InvestigateWidgetCreate,
InvestigationNote,
} from './types';

export { mergePlainObjects } from './utils/merge_plain_objects';
38 changes: 0 additions & 38 deletions x-pack/plugins/observability_solution/investigate/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,9 @@
* 2.0.
*/

import type { DeepPartial } from 'utility-types';

export interface GlobalWidgetParameters {
timeRange: {
from: string;
to: string;
};
}

export interface Investigation {
id: string;
createdAt: number;
title: string;
items: InvestigateWidget[];
notes: InvestigationNote[];
parameters: GlobalWidgetParameters;
}

export interface InvestigationNote {
id: string;
createdAt: number;
createdBy: string;
content: string;
}

export interface InvestigateWidget<
TParameters extends Record<string, any> = {},
TData extends Record<string, any> = {}
> {
id: string;
createdAt: number;
createdBy: string;
title: string;
type: string;
parameters: GlobalWidgetParameters & TParameters;
data: TData;
}

export type InvestigateWidgetCreate<TParameters extends Record<string, any> = {}> = Pick<
InvestigateWidget,
'title' | 'type'
> & {
parameters: DeepPartial<GlobalWidgetParameters> & TParameters;
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a570d94

Please sign in to comment.