Skip to content

Commit

Permalink
rename entityv2
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Nov 22, 2024
1 parent 2606a06 commit f904abb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x-pack/packages/kbn-entities-schema/src/schema/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface MetadataRecord {
[key: string]: string[] | MetadataRecord | string;
}

export interface Entity {
export interface EntityV2 {
'entity.id': string;
'entity.last_seen_timestamp': string;
'entity.type': string;
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/entity_manager/server/lib/entity_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Entity, EntityDefinition, EntityDefinitionUpdate } from '@kbn/entities-schema';
import { EntityV2, EntityDefinition, EntityDefinitionUpdate } from '@kbn/entities-schema';
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { Logger } from '@kbn/logging';
Expand Down Expand Up @@ -266,7 +266,10 @@ export class EntityClient {
});
this.options.logger.debug(`Entity query: ${query}`);

const rawEntities = await runESQLQuery<Entity>({ query, esClient: this.options.esClient });
const rawEntities = await runESQLQuery<EntityV2>({
query,
esClient: this.options.esClient,
});

return rawEntities.map((entity) => {
entity['entity.id'] = source.identity_fields.map((field) => entity[field]).join(':');
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/entity_manager/server/lib/queries/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { Entity } from '@kbn/entities-schema';
import { EntityV2 } from '@kbn/entities-schema';
import { ESQLSearchResponse } from '@kbn/es-types';
import { uniq } from 'lodash';

function mergeEntities(entity1: Entity, entity2: Entity): Entity {
const merged: Entity = {
function mergeEntities(entity1: EntityV2, entity2: EntityV2): EntityV2 {
const merged: EntityV2 = {
...entity1,
'entity.last_seen_timestamp': new Date(
Math.max(
Expand All @@ -36,8 +36,8 @@ function mergeEntities(entity1: Entity, entity2: Entity): Entity {
return merged;
}

export function mergeEntitiesList(entities: Entity[]): Entity[] {
const instances: { [key: string]: Entity } = {};
export function mergeEntitiesList(entities: EntityV2[]): EntityV2[] {
const instances: { [key: string]: EntityV2 } = {};

for (let i = 0; i < entities.length; i++) {
const entity = entities[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { Entity } from '@kbn/entities-schema';
import { EntityV2 } from '@kbn/entities-schema';
import { usePluginContext } from '../../hooks/use_plugin_context';

function EntitySourceForm({
Expand Down Expand Up @@ -137,7 +137,7 @@ const newEntitySource = ({

export function EntityManagerOverviewPage() {
const { ObservabilityPageTemplate, entityClient } = usePluginContext();
const [previewEntities, setPreviewEntities] = useState<Entity[]>([]);
const [previewEntities, setPreviewEntities] = useState<EntityV2[]>([]);
const [isSearchingEntities, setIsSearchingEntities] = useState(false);
const [previewError, setPreviewError] = useState(null);
const [formErrors, setFormErrors] = useState<string[]>([]);
Expand Down

0 comments on commit f904abb

Please sign in to comment.