-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Inventory][ECO] Replace Entity
with InventoryEntityLatest
type
#198760
Conversation
222c45c
to
a597446
Compare
a597446
to
8ba7131
Compare
entity
typeEntity
with InventoryEntityLatest
type
@@ -11,9 +11,9 @@ import { arrayOfStringsSchema } from './common'; | |||
export const entityBaseSchema = z.object({ | |||
id: z.string(), | |||
type: z.string(), | |||
identity_fields: arrayOfStringsSchema, | |||
identity_fields: z.union([arrayOfStringsSchema, z.string()]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esql
returns a string
when fields hold a single value.
display_name: z.string(), | ||
metrics: z.record(z.string(), z.number()), | ||
metrics: z.optional(z.record(z.string(), z.number())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we should remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The framework still supports metrics even if the Inventory doesn't use it, let's leave this for now
...ugins/observability_solution/inventory/public/components/entities_grid/entity_name/index.tsx
Outdated
Show resolved
Hide resolved
...ability_solution/inventory/public/components/grouped_inventory/inventory_group_accordion.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/observability_solution/inventory/server/routes/entities/get_entity_types.ts
Outdated
Show resolved
Hide resolved
4afe580
to
9321024
Compare
/ci |
export type InventoryEntityLatest = { | ||
entityId: string; | ||
entityType: string; | ||
entityIdentityFields: string | string[]; | ||
entityDisplayName: string; | ||
entityDefinitionId: string; | ||
entityLastSeenTimestamp: string; | ||
entityDefinitionVersion: string; | ||
entitySchemaVersion: string; | ||
alertsCount?: number; | ||
}; | ||
} & z.infer<typeof entityMetadataSchema>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to make the API return an interface that doesn't depend in the index mapping. The Metadata, however, will return the objects as they are returned from the query
@elasticmachine merge upstream |
/ci |
x-pack/plugins/observability_solution/inventory/public/hooks/use_detail_view_redirect.ts
Outdated
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
History
|
@elasticmachine merge upstream |
x-pack/packages/observability/observability_utils/es/client/create_observability_es_client.ts
Outdated
Show resolved
Hide resolved
const identityFieldsValue = this.getIdentityFieldsValue(entityLatest); | ||
asKqlFilter( | ||
entityInstance: { | ||
entity: Pick<EntityInstance['entity'], 'identity_fields'>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an entity
this is an identity_fields
, can 't you create a type for the identity_fields
and use it here and in the entityBaseSchema
?
const identityFieldsSchema = z.union([arrayOfStringsSchema, z.string()]);
export type IdentityFields = z.infer<typeof identityFieldsSchema>;
export const entityBaseSchema = z.object({
id: z.string(),
type: z.string(),
identity_fields: identityFieldsSchema,
entity: Pick<EntityInstance['entity'], 'identity_fields'>; | |
identityFields: IdentityFields; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a partial entity
. I'll see if this can be improved.
x-pack/plugins/observability_solution/inventory/common/utils/entity_type_guards.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/observability_solution/inventory/common/utils/entity_type_guards.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/observability_solution/inventory/server/routes/entities/get_entity_types.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entities changes LGTM
display_name: z.string(), | ||
metrics: z.record(z.string(), z.number()), | ||
metrics: z.optional(z.record(z.string(), z.number())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The framework still supports metrics even if the Inventory doesn't use it, let's leave this for now
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
History
|
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…lastic#198760) closes [elastic#198758](elastic#198758) ## Summary This PR removes the Entity type used across the Inventory and replaces it with `InventoryEntityLatest`, which provides strong typing for the latest entity object. This change makes the code leverage TypeScript’s intellisense and autocompletion in the editor, making the code easier to work with and more maintainable across the codebase. `InventoryEntityLatest` is the interface that the API returns and what the UI consumes. Note that this is distinct from the index mapping defined by `entityLatestSchema`, creating a separation layer between Elasticsearch and the UI. --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit c4d3de8) # Conflicts: # x-pack/plugins/observability_solution/apm/ftr_e2e/cypress/e2e/transaction_details/transaction_details.cy.ts
…type (#198760) (#199967) # Backport This will backport the following commits from `main` to `8.x`: - [[Inventory][ECO] Replace `Entity` with `InventoryEntityLatest` type (#198760)](#198760) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Carlos Crespo","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-12T17:47:00Z","message":"[Inventory][ECO] Replace `Entity` with `InventoryEntityLatest` type (#198760)\n\ncloses [#198758](https://github.com/elastic/kibana/issues/198758)\r\n\r\n## Summary\r\n\r\nThis PR removes the Entity type used across the Inventory and replaces\r\nit with `InventoryEntityLatest`, which provides strong typing for the\r\nlatest entity object. This change makes the code leverage TypeScript’s\r\nintellisense and autocompletion in the editor, making the code easier to\r\nwork with and more maintainable across the codebase.\r\n\r\n`InventoryEntityLatest` is the interface that the API returns and what\r\nthe UI consumes. Note that this is distinct from the index mapping\r\ndefined by `entityLatestSchema`, creating a separation layer between\r\nElasticsearch and the UI.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"c4d3de83162904d3db19e82720b2dd747dcfc5e6","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"number":198760,"url":"https://github.com/elastic/kibana/pull/198760","mergeCommit":{"message":"[Inventory][ECO] Replace `Entity` with `InventoryEntityLatest` type (#198760)\n\ncloses [#198758](https://github.com/elastic/kibana/issues/198758)\r\n\r\n## Summary\r\n\r\nThis PR removes the Entity type used across the Inventory and replaces\r\nit with `InventoryEntityLatest`, which provides strong typing for the\r\nlatest entity object. This change makes the code leverage TypeScript’s\r\nintellisense and autocompletion in the editor, making the code easier to\r\nwork with and more maintainable across the codebase.\r\n\r\n`InventoryEntityLatest` is the interface that the API returns and what\r\nthe UI consumes. Note that this is distinct from the index mapping\r\ndefined by `entityLatestSchema`, creating a separation layer between\r\nElasticsearch and the UI.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"c4d3de83162904d3db19e82720b2dd747dcfc5e6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198760","number":198760,"mergeCommit":{"message":"[Inventory][ECO] Replace `Entity` with `InventoryEntityLatest` type (#198760)\n\ncloses [#198758](https://github.com/elastic/kibana/issues/198758)\r\n\r\n## Summary\r\n\r\nThis PR removes the Entity type used across the Inventory and replaces\r\nit with `InventoryEntityLatest`, which provides strong typing for the\r\nlatest entity object. This change makes the code leverage TypeScript’s\r\nintellisense and autocompletion in the editor, making the code easier to\r\nwork with and more maintainable across the codebase.\r\n\r\n`InventoryEntityLatest` is the interface that the API returns and what\r\nthe UI consumes. Note that this is distinct from the index mapping\r\ndefined by `entityLatestSchema`, creating a separation layer between\r\nElasticsearch and the UI.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"c4d3de83162904d3db19e82720b2dd747dcfc5e6"}}]}] BACKPORT-->
…lastic#198760) closes [elastic#198758](elastic#198758) ## Summary This PR removes the Entity type used across the Inventory and replaces it with `InventoryEntityLatest`, which provides strong typing for the latest entity object. This change makes the code leverage TypeScript’s intellisense and autocompletion in the editor, making the code easier to work with and more maintainable across the codebase. `InventoryEntityLatest` is the interface that the API returns and what the UI consumes. Note that this is distinct from the index mapping defined by `entityLatestSchema`, creating a separation layer between Elasticsearch and the UI. --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]>
…lastic#198760) closes [elastic#198758](elastic#198758) ## Summary This PR removes the Entity type used across the Inventory and replaces it with `InventoryEntityLatest`, which provides strong typing for the latest entity object. This change makes the code leverage TypeScript’s intellisense and autocompletion in the editor, making the code easier to work with and more maintainable across the codebase. `InventoryEntityLatest` is the interface that the API returns and what the UI consumes. Note that this is distinct from the index mapping defined by `entityLatestSchema`, creating a separation layer between Elasticsearch and the UI. --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]>
closes #198758
Summary
This PR removes the Entity type used across the Inventory and replaces it with
InventoryEntityLatest
, which provides strong typing for the latest entity object. This change makes the code leverage TypeScript’s intellisense and autocompletion in the editor, making the code easier to work with and more maintainable across the codebase.InventoryEntityLatest
is the interface that the API returns and what the UI consumes. Note that this is distinct from the index mapping defined byentityLatestSchema
, creating a separation layer between Elasticsearch and the UI.