Skip to content

Commit

Permalink
[Logs UI] Decouple log view HTTP API schema from saved object schema (#…
Browse files Browse the repository at this point in the history
…158098)

Resolves #152278.

Separates out the type for saved object
`infrastructure-monitoring-log-view` so the HTTP API no longer
references the same type.
  • Loading branch information
neptunian authored May 23, 2023
1 parent 8fcc8aa commit 8e0123e
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions x-pack/plugins/infra/server/saved_objects/log_view/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,61 @@

import { isoToEpochRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
import { logViewAttributesRT } from '../../../common/log_views';
import { savedObjectReferenceRT } from '../references';

export const logDataViewSavedObjectReferenceRT = rt.type({
type: rt.literal('data_view'),
dataViewId: rt.string,
});

export const logIndexNameSavedObjectReferenceRT = rt.type({
type: rt.literal('index_name'),
indexName: rt.string,
});

export const logIndexSavedObjectReferenceRT = rt.union([
logDataViewSavedObjectReferenceRT,
logIndexNameSavedObjectReferenceRT,
]);

const logViewSavedObjectCommonColumnConfigurationRT = rt.strict({
id: rt.string,
});

const logViewSavedObjectTimestampColumnConfigurationRT = rt.strict({
timestampColumn: logViewSavedObjectCommonColumnConfigurationRT,
});

const logViewSavedObjectMessageColumnConfigurationRT = rt.strict({
messageColumn: logViewSavedObjectCommonColumnConfigurationRT,
});

export const logViewSavedObjectFieldColumnConfigurationRT = rt.strict({
fieldColumn: rt.intersection([
logViewSavedObjectCommonColumnConfigurationRT,
rt.strict({
field: rt.string,
}),
]),
});

export const logViewSavedObjectColumnConfigurationRT = rt.union([
logViewSavedObjectTimestampColumnConfigurationRT,
logViewSavedObjectMessageColumnConfigurationRT,
logViewSavedObjectFieldColumnConfigurationRT,
]);

export const logViewSavedObjectAttributesRT = rt.strict({
name: rt.string,
description: rt.string,
logIndices: logIndexSavedObjectReferenceRT,
logColumns: rt.array(logViewSavedObjectColumnConfigurationRT),
});

export const logViewSavedObjectRT = rt.intersection([
rt.type({
id: rt.string,
attributes: logViewAttributesRT,
attributes: logViewSavedObjectAttributesRT,
references: rt.array(savedObjectReferenceRT),
}),
rt.partial({
Expand Down

0 comments on commit 8e0123e

Please sign in to comment.