Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Fleet APIs using kbn/config-schema part 3 #193698

Merged
merged 18 commits into from
Oct 3, 2024
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ interface AgentBase {
policy_id?: string;
policy_revision?: number | null;
last_checkin?: string;
last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating';
last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating' | 'starting';
last_checkin_message?: string;
user_provided_metadata: AgentMetadata;
user_provided_metadata?: AgentMetadata;
local_metadata: AgentMetadata;
tags?: string[];
components?: FleetServerAgentComponent[];
Expand Down Expand Up @@ -272,7 +272,7 @@ export interface FleetServerAgent {
/**
* User provided metadata information for the Elastic Agent
*/
user_provided_metadata: AgentMetadata;
user_provided_metadata?: AgentMetadata;
/**
* Local metadata information for the Elastic Agent
*/
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export interface NewAgentPolicy {
enabled: boolean;
host?: string;
port?: number;
buffer?: {
enabled: boolean;
};
};
monitoring_diagnostics?: {
limit?: {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ type RegistryOverridesToOptional = Pick<PackageSpecManifest, 'title' | 'release'
// and confirm with Registry if they are really optional. Can update types and ~4 places in code later if neccessary
interface RegistryAdditionalProperties {
assets?: string[];
download: string;
download?: string;
signature_path?: string;
path: string;
path?: string;
readme?: string;
internal?: boolean; // Registry addition[0] and EPM uses it[1] [0]: https://github.com/elastic/package-registry/blob/dd7b021893aa8d66a5a5fde963d8ff2792a9b8fa/util/package.go#L63 [1]
data_streams?: RegistryDataStream[]; // Registry addition [0] [0]: https://github.com/elastic/package-registry/blob/dd7b021893aa8d66a5a5fde963d8ff2792a9b8fa/util/package.go#L65
Expand Down Expand Up @@ -317,9 +317,9 @@ export interface AssetParts {
export type AssetTypeToParts = KibanaAssetTypeToParts & ElasticsearchAssetTypeToParts;
export type AssetsGroupedByServiceByType = Record<
Extract<ServiceName, 'kibana'>,
KibanaAssetTypeToParts
KibanaAssetTypeToParts | undefined
> &
Record<Extract<ServiceName, 'elasticsearch'>, ElasticsearchAssetTypeToParts>;
Record<Extract<ServiceName, 'elasticsearch'>, ElasticsearchAssetTypeToParts | undefined>;

export type KibanaAssetParts = AssetParts & {
service: Extract<ServiceName, 'kibana'>;
Expand Down Expand Up @@ -534,7 +534,7 @@ export type PackageInfo =
| Installable<Merge<ArchivePackage, EpmPackageAdditions>>;

export interface PackageMetadata {
has_policies: true;
has_policies: boolean;
}

export type IntegrationCardReleaseLabel = 'beta' | 'preview' | 'ga' | 'rc';
Expand Down
14 changes: 8 additions & 6 deletions x-pack/plugins/fleet/common/types/models/package_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type { RegistryElasticsearch, RegistryPolicyTemplate, RegistryVarsEntry }

// Based on https://github.com/elastic/package-spec/blob/master/versions/1/manifest.spec.yml#L8
export interface PackageSpecManifest {
format_version: string;
format_version?: string;
name: string;
title: string;
description: string;
description?: string;
version: string;
license?: 'basic';
source?: {
Expand All @@ -26,7 +26,7 @@ export interface PackageSpecManifest {
screenshots?: PackageSpecScreenshot[];
policy_templates?: RegistryPolicyTemplate[];
vars?: RegistryVarsEntry[];
owner: { github: string; type?: 'elastic' | 'partner' | 'community' };
owner: { github?: string; type?: 'elastic' | 'partner' | 'community' };
elasticsearch?: Pick<
RegistryElasticsearch,
'index_template.settings' | 'index_template.mappings' | 'index_template.data_stream'
Expand Down Expand Up @@ -113,11 +113,12 @@ export type PackageSpecCategory =
| 'workplace_search_content_source';

export interface PackageSpecConditions {
kibana: {
version: string;
kibana?: {
version?: string;
};
elastic?: {
subscription: string;
subscription?: string;
capabilities?: string[];
};
}

Expand All @@ -126,6 +127,7 @@ export interface PackageSpecIcon {
title?: string;
size?: string;
type?: string;
dark_mode?: boolean;
}

export interface PackageSpecScreenshot {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/common/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import type { SortResults } from '@elastic/elasticsearch/lib/api/types';

import type { PackageSpecIcon } from '../models/package_spec';
import type {
AssetReference,
CategorySummaryList,
Expand Down Expand Up @@ -61,6 +62,9 @@ export interface InstalledPackage {
name: string;
title: string;
}>;
title?: string;
description?: string;
icons?: PackageSpecIcon[];
}
export interface GetInstalledPackagesResponse {
items: InstalledPackage[];
Expand Down Expand Up @@ -160,7 +164,7 @@ export interface InstallResult {
status?: InstallResultStatus;
error?: Error;
installType: InstallType;
installSource: InstallSource;
installSource?: InstallSource;
}

export interface BulkInstallPackageInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const SettingsPage: React.FC<Props> = memo(
numOfAssets: Object.entries(packageInfo.assets).reduce(
(acc, [serviceName, serviceNameValue]) =>
acc +
Object.entries(serviceNameValue).reduce(
Object.entries(serviceNameValue || {}).reduce(
(acc2, [assetName, assetNameValue]) => acc2 + assetNameValue.length,
0
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const mapToCard = ({

return {
id: `${item.type === 'ui_link' ? 'ui_link' : 'epr'}:${item.id}`,
description: item.description,
description: item.description || '',
icons: !item.icons || !item.icons.length ? [] : item.icons,
title: item.title,
url: uiInternalPathUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import type { PackageInfo } from '../../common';
export const getNumTransformAssets = (assets?: PackageInfo['assets']) => {
if (
!assets ||
!(Array.isArray(assets.elasticsearch?.transform) && assets.elasticsearch?.transform?.length > 0)
!(
Array.isArray(assets.elasticsearch?.transform) &&
(assets.elasticsearch?.transform?.length ?? 0) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this change? small bug in the UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made transform optional in TS type as it came up as an error in schema validation (sometimes undefined), and then tsc started complaining about transform?.length possibly undefined

)
) {
return 0;
}
Expand Down
Loading