Skip to content

Commit

Permalink
Make "type" exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry350 committed May 9, 2023
1 parent 8cf8a1e commit ed121b5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/types/models/data_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ export interface DataStream {
serviceName: string;
} | null;
}

export type PackageDataStreamTypes = 'logs' | 'metrics' | 'traces' | 'synthetics' | 'profiling';
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/server/services/epm/data_streams/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

import type { ElasticsearchClient } from '@kbn/core/server';

import type { PackageDataStreamTypes } from '../../../../common/types';

import { dataStreamService } from '../../data_streams';

export async function getDataStreams(options: {
esClient: ElasticsearchClient;
type?: 'logs' | 'metrics' | 'traces';
type?: PackageDataStreamTypes;
datasetQuery?: string;
sortDirection: 'asc' | 'desc';
uncategorisedOnly: boolean;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/services/epm/packages/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
PackageUsageStats,
PackagePolicySOAttributes,
Installable,
PackageDataStreamTypes,
} from '../../../../common/types';
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
import type {
Expand Down Expand Up @@ -151,7 +152,7 @@ export async function getPackages(

export async function getInstalledPackages(options: {
savedObjectsClient: SavedObjectsClientContract;
type?: 'logs' | 'metrics' | 'traces';
type?: PackageDataStreamTypes;
nameQuery?: string;
pageAfter?: SortResults;
pageSize: number;
Expand Down Expand Up @@ -219,7 +220,6 @@ export async function getInstalledPackages(options: {
});

return {
// icons: string; // TODO: implement
name,
version,
status: installStatus,
Expand Down
16 changes: 14 additions & 2 deletions x-pack/plugins/fleet/server/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export const GetPackagesRequestSchema = {
export const GetInstalledPackagesRequestSchema = {
query: schema.object({
type: schema.maybe(
schema.oneOf([schema.literal('logs'), schema.literal('metrics'), schema.literal('traces')])
schema.oneOf([
schema.literal('logs'),
schema.literal('metrics'),
schema.literal('traces'),
schema.literal('synthetics'),
schema.literal('profiling'),
])
),
nameQuery: schema.maybe(schema.string()),
pageAfter: schema.maybe(schema.arrayOf(schema.oneOf([schema.string(), schema.number()]))),
Expand All @@ -41,7 +47,13 @@ export const GetInstalledPackagesRequestSchema = {
export const GetDataStreamsRequestSchema = {
query: schema.object({
type: schema.maybe(
schema.oneOf([schema.literal('logs'), schema.literal('metrics'), schema.literal('traces')])
schema.oneOf([
schema.literal('logs'),
schema.literal('metrics'),
schema.literal('traces'),
schema.literal('synthetics'),
schema.literal('profiling'),
])
),
datasetQuery: schema.maybe(schema.string()),
sortDirection: schema.oneOf([schema.literal('asc'), schema.literal('desc')], {
Expand Down

0 comments on commit ed121b5

Please sign in to comment.