Skip to content

Commit

Permalink
Revert "fix/service-node-graph-metadata (#964)" (#971)
Browse files Browse the repository at this point in the history
* Revert "fix/service-node-graph-metadata (#964)"

This reverts commit 2ad9561.

* Create unlucky-eggs-develop.md
  • Loading branch information
boyney123 authored Nov 25, 2024
1 parent df553d8 commit a904248
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-eggs-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/core": patch
---

Revert "fix/service-node-graph-metadata (#964)"
14 changes: 7 additions & 7 deletions src/utils/__tests__/domains/node-graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Domains NodeGraph', () => {
id: 'OrderPlaced-0.0.1',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[0].id }) },
data: { mode: 'simple', message: mockEvents[0] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
};
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Domains NodeGraph', () => {
id: 'PlaceOrder-1.7.7',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockCommands[2].id }) },
data: { mode: 'simple', message: mockCommands[2] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'commands',
},
Expand All @@ -114,7 +114,7 @@ describe('Domains NodeGraph', () => {
id: 'OrderPlaced-0.0.1',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[0].id }) },
data: { mode: 'simple', message: mockEvents[0] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
},
Expand All @@ -134,31 +134,31 @@ describe('Domains NodeGraph', () => {
id: 'PaymentPaid-0.0.1',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[1].id }) },
data: { mode: 'simple', message: mockEvents[1] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
},
{
id: 'PaymentPaid-0.0.2',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[2].id }) },
data: { mode: 'simple', message: mockEvents[2] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
},
{
id: 'PaymentRefunded-1.0.0',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[4].id }) },
data: { mode: 'simple', message: mockEvents[4] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
},
{
id: 'PaymentFailed-1.0.0',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[6].id }) },
data: { mode: 'simple', message: mockEvents[6] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
},
Expand Down
14 changes: 0 additions & 14 deletions src/utils/__tests__/services/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const mockServices = [

export const mockEvents = [
{
id: 'events/OrderCreatedEvent/versioned/0.0.1/index.mdx',
slug: 'OrderCreatedEvent',
collection: 'events',
data: {
Expand All @@ -102,7 +101,6 @@ export const mockEvents = [
},
},
{
id: 'events/OrderCreatedEvent/versioned/1.0.0/index.mdx',
slug: 'OrderCreatedEvent',
collection: 'events',
data: {
Expand All @@ -111,7 +109,6 @@ export const mockEvents = [
},
},
{
id: 'events/OrderCreatedEvent/versioned/1.3.9/index.mdx',
slug: 'OrderCreatedEvent',
collection: 'events',
data: {
Expand All @@ -120,7 +117,6 @@ export const mockEvents = [
},
},
{
id: 'events/OrderCreatedEvent/index.mdx',
slug: 'OrderCreatedEvent',
collection: 'events',
data: {
Expand All @@ -129,7 +125,6 @@ export const mockEvents = [
},
},
{
id: 'events/OrderDeletedEvent/index.mdx',
slug: 'OrderDeletedEvent',
collection: 'events',
data: {
Expand All @@ -144,7 +139,6 @@ export const mockEvents = [
},
},
{
id: 'events/InventoryAdjusted/versioned/0.0.1/index.mdx',
slug: 'InventoryAdjusted',
collection: 'events',
data: {
Expand All @@ -153,7 +147,6 @@ export const mockEvents = [
},
},
{
id: 'events/InventoryAdjusted/versioned/1.0.0/index.mdx',
slug: 'InventoryAdjusted',
collection: 'events',
data: {
Expand All @@ -162,7 +155,6 @@ export const mockEvents = [
},
},
{
id: 'events/InventoryAdjusted/index.mdx',
slug: 'InventoryAdjusted',
collection: 'events',
data: {
Expand All @@ -172,7 +164,6 @@ export const mockEvents = [
},
// 7
{
id: 'events/PaymentPaid/versioned/1.0.0/index.mdx',
slug: 'PaymentPaid',
collection: 'events',
data: {
Expand All @@ -182,7 +173,6 @@ export const mockEvents = [
},
// 9
{
id: 'events/PaymentPaid/index.mdx',
slug: 'PaymentPaid',
collection: 'events',
data: {
Expand All @@ -192,7 +182,6 @@ export const mockEvents = [
},
// 10
{
id: 'events/PaymentFailed/versioned/1.0.0/index.mdx',
slug: 'PaymentFailed',
collection: 'events',
data: {
Expand All @@ -202,7 +191,6 @@ export const mockEvents = [
},
// 11
{
id: 'events/PaymentFailed/1.2.3/index.mdx',
slug: 'PaymentFailed',
collection: 'events',
data: {
Expand Down Expand Up @@ -230,7 +218,6 @@ export const mockEvents = [

export const mockCommands = [
{
id: 'commands/PaymentProcessed/index.mdx',
slug: 'PaymentProcessed',
collection: 'commands',
data: {
Expand All @@ -241,7 +228,6 @@ export const mockCommands = [
];
export const mockQueries = [
{
id: 'queries/GetOrder/index.mdx',
slug: 'GetOrder',
collection: 'queries',
data: {
Expand Down
52 changes: 6 additions & 46 deletions src/utils/__tests__/services/node-graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Services NodeGraph', () => {
type: 'commands',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockCommands[0].id }) },
data: { mode: 'simple', message: mockCommands[0] },
position: { x: expect.any(Number), y: expect.any(Number) },
};

Expand All @@ -59,7 +59,7 @@ describe('Services NodeGraph', () => {
id: 'OrderCreatedEvent-0.0.1',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[0].id }) },
data: { mode: 'simple', message: mockEvents[0] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
};
Expand Down Expand Up @@ -115,46 +115,6 @@ describe('Services NodeGraph', () => {
expect(edges).toEqual(expectedEdges);
});

it('should return message nodes with producers and consumers for a given service', async () => {
const { nodes } = await getNodesAndEdges({ id: 'OrderService', version: '1.0.0' });

const expectedRecivesNode = {
id: 'PaymentProcessed-0.0.1',
type: 'commands',
data: expect.objectContaining({
message: expect.objectContaining({
data: expect.objectContaining({
consumers: [expect.objectContaining(mockServices[0])],
producers: expect.any(Array),
}),
}),
}),
};

const expectedSendsNode = {
id: 'OrderCreatedEvent-0.0.1',
type: 'events',
data: expect.objectContaining({
message: expect.objectContaining({
data: expect.objectContaining({
consumers: expect.any(Array),
producers: [expect.objectContaining(mockServices[0])],
}),
}),
}),
};

expect(nodes).toEqual(
expect.arrayContaining([
// Nodes on the left
expect.objectContaining(expectedRecivesNode),

// Nodes on the right
expect.objectContaining(expectedSendsNode),
])
);
});

it('if a message is sent and received by the same service it will render a custom edge', async () => {
const { nodes, edges } = await getNodesAndEdges({ id: 'NotificationsService', version: '1.0.0' });

Expand All @@ -174,7 +134,7 @@ describe('Services NodeGraph', () => {
type: 'events',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[3].id }) },
data: { mode: 'simple', message: mockEvents[3] },
position: { x: expect.any(Number), y: expect.any(Number) },
};

Expand All @@ -183,7 +143,7 @@ describe('Services NodeGraph', () => {
id: 'OrderCreatedEvent-2.0.0',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[3].id }) },
data: { mode: 'simple', message: mockEvents[3] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
};
Expand Down Expand Up @@ -263,7 +223,7 @@ describe('Services NodeGraph', () => {
type: 'events',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[2].id }) },
data: { mode: 'simple', message: mockEvents[2] },
position: { x: expect.any(Number), y: expect.any(Number) },
};

Expand All @@ -272,7 +232,7 @@ describe('Services NodeGraph', () => {
id: 'InventoryAdjusted-2.0.0',
sourcePosition: 'right',
targetPosition: 'left',
data: { mode: 'simple', message: expect.objectContaining({ id: mockEvents[7].id }) },
data: { mode: 'simple', message: mockEvents[7] },
position: { x: expect.any(Number), y: expect.any(Number) },
type: 'events',
};
Expand Down
12 changes: 4 additions & 8 deletions src/utils/node-graphs/services-node-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import {
import { findMatchingNodes, getItemsFromCollectionByIdAndSemverOrLatest } from '@utils/collections/util';
import { MarkerType } from 'reactflow';
import type { CollectionMessageTypes } from '@types';
import { getCommands } from '@utils/commands';
import { getEvents } from '@utils/events';
import { getQueries } from '@utils/queries';
import { getChannels } from '@utils/channels';

type DagreGraph = any;

Expand Down Expand Up @@ -71,10 +67,10 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
const receivesRaw = service?.data.receives || [];
const sendsRaw = service?.data.sends || [];

const events = await getEvents();
const commands = await getCommands();
const queries = await getQueries();
const channels = await getChannels();
const events = await getCollection('events');
const commands = await getCollection('commands');
const queries = await getCollection('queries');
const channels = await getCollection('channels');

const messages = [...events, ...commands, ...queries];

Expand Down

0 comments on commit a904248

Please sign in to comment.