Skip to content

Commit

Permalink
Add types to return content packages correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Oct 8, 2024
1 parent 2dfd8f1 commit 5fbbba8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions x-pack/plugins/fleet/common/types/models/package_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface PackageSpecManifest {
source?: {
license: string;
};
type?: 'integration' | 'input';
type?: PackageSpecPackageType;
release?: 'experimental' | 'beta' | 'ga';
categories?: Array<PackageSpecCategory | undefined>;
conditions?: PackageSpecConditions;
Expand All @@ -35,14 +35,19 @@ export interface PackageSpecManifest {
privileges?: { root?: boolean };
};
asset_tags?: PackageSpecTags[];
discovery?: {
fields?: Array<{
name: string;
}>;
};
}
export interface PackageSpecTags {
text: string;
asset_types?: string[];
asset_ids?: string[];
}

export type PackageSpecPackageType = 'integration' | 'input';
export type PackageSpecPackageType = 'integration' | 'input' | 'content';

export type PackageSpecCategory =
| 'advanced_analytics_ueba'
Expand Down
13 changes: 12 additions & 1 deletion x-pack/plugins/fleet/server/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ export const PackageInfoSchema = schema
release: schema.maybe(
schema.oneOf([schema.literal('ga'), schema.literal('beta'), schema.literal('experimental')])
),
type: schema.maybe(schema.oneOf([schema.literal('integration'), schema.literal('input')])),
type: schema.maybe(
schema.oneOf([
schema.literal('integration'),
schema.literal('input'),
schema.literal('content'),
])
),
path: schema.maybe(schema.string()),
download: schema.maybe(schema.string()),
internal: schema.maybe(schema.boolean()),
Expand Down Expand Up @@ -192,6 +198,11 @@ export const PackageInfoSchema = schema
format_version: schema.maybe(schema.string()),
vars: schema.maybe(schema.arrayOf(schema.recordOf(schema.string(), schema.any()))),
latestVersion: schema.maybe(schema.string()),
discovery: schema.maybe(
schema.object({
fields: schema.maybe(schema.arrayOf(schema.object({ name: schema.string() }))),
})
),
})
// sometimes package list response contains extra properties, e.g. installed_kibana
.extendsDeep({
Expand Down

0 comments on commit 5fbbba8

Please sign in to comment.