diff --git a/.changeset/unlucky-eggs-develop.md b/.changeset/unlucky-eggs-develop.md new file mode 100644 index 00000000..35f63a74 --- /dev/null +++ b/.changeset/unlucky-eggs-develop.md @@ -0,0 +1,5 @@ +--- +"@eventcatalog/core": patch +--- + +Revert "fix/service-node-graph-metadata (#964)" diff --git a/src/utils/__tests__/domains/node-graph.spec.ts b/src/utils/__tests__/domains/node-graph.spec.ts index 2b3d46b7..6de3a459 100644 --- a/src/utils/__tests__/domains/node-graph.spec.ts +++ b/src/utils/__tests__/domains/node-graph.spec.ts @@ -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', }; @@ -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', }, @@ -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', }, @@ -134,7 +134,7 @@ 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', }, @@ -142,7 +142,7 @@ describe('Domains NodeGraph', () => { 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', }, @@ -150,7 +150,7 @@ describe('Domains NodeGraph', () => { 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', }, @@ -158,7 +158,7 @@ describe('Domains NodeGraph', () => { 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', }, diff --git a/src/utils/__tests__/services/mocks.ts b/src/utils/__tests__/services/mocks.ts index 18dc450b..ccbdd6ff 100644 --- a/src/utils/__tests__/services/mocks.ts +++ b/src/utils/__tests__/services/mocks.ts @@ -93,7 +93,6 @@ export const mockServices = [ export const mockEvents = [ { - id: 'events/OrderCreatedEvent/versioned/0.0.1/index.mdx', slug: 'OrderCreatedEvent', collection: 'events', data: { @@ -102,7 +101,6 @@ export const mockEvents = [ }, }, { - id: 'events/OrderCreatedEvent/versioned/1.0.0/index.mdx', slug: 'OrderCreatedEvent', collection: 'events', data: { @@ -111,7 +109,6 @@ export const mockEvents = [ }, }, { - id: 'events/OrderCreatedEvent/versioned/1.3.9/index.mdx', slug: 'OrderCreatedEvent', collection: 'events', data: { @@ -120,7 +117,6 @@ export const mockEvents = [ }, }, { - id: 'events/OrderCreatedEvent/index.mdx', slug: 'OrderCreatedEvent', collection: 'events', data: { @@ -129,7 +125,6 @@ export const mockEvents = [ }, }, { - id: 'events/OrderDeletedEvent/index.mdx', slug: 'OrderDeletedEvent', collection: 'events', data: { @@ -144,7 +139,6 @@ export const mockEvents = [ }, }, { - id: 'events/InventoryAdjusted/versioned/0.0.1/index.mdx', slug: 'InventoryAdjusted', collection: 'events', data: { @@ -153,7 +147,6 @@ export const mockEvents = [ }, }, { - id: 'events/InventoryAdjusted/versioned/1.0.0/index.mdx', slug: 'InventoryAdjusted', collection: 'events', data: { @@ -162,7 +155,6 @@ export const mockEvents = [ }, }, { - id: 'events/InventoryAdjusted/index.mdx', slug: 'InventoryAdjusted', collection: 'events', data: { @@ -172,7 +164,6 @@ export const mockEvents = [ }, // 7 { - id: 'events/PaymentPaid/versioned/1.0.0/index.mdx', slug: 'PaymentPaid', collection: 'events', data: { @@ -182,7 +173,6 @@ export const mockEvents = [ }, // 9 { - id: 'events/PaymentPaid/index.mdx', slug: 'PaymentPaid', collection: 'events', data: { @@ -192,7 +182,6 @@ export const mockEvents = [ }, // 10 { - id: 'events/PaymentFailed/versioned/1.0.0/index.mdx', slug: 'PaymentFailed', collection: 'events', data: { @@ -202,7 +191,6 @@ export const mockEvents = [ }, // 11 { - id: 'events/PaymentFailed/1.2.3/index.mdx', slug: 'PaymentFailed', collection: 'events', data: { @@ -230,7 +218,6 @@ export const mockEvents = [ export const mockCommands = [ { - id: 'commands/PaymentProcessed/index.mdx', slug: 'PaymentProcessed', collection: 'commands', data: { @@ -241,7 +228,6 @@ export const mockCommands = [ ]; export const mockQueries = [ { - id: 'queries/GetOrder/index.mdx', slug: 'GetOrder', collection: 'queries', data: { diff --git a/src/utils/__tests__/services/node-graph.spec.ts b/src/utils/__tests__/services/node-graph.spec.ts index 5d6c7c32..f20ad1a3 100644 --- a/src/utils/__tests__/services/node-graph.spec.ts +++ b/src/utils/__tests__/services/node-graph.spec.ts @@ -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) }, }; @@ -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', }; @@ -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' }); @@ -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) }, }; @@ -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', }; @@ -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) }, }; @@ -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', }; diff --git a/src/utils/node-graphs/services-node-graph.ts b/src/utils/node-graphs/services-node-graph.ts index 21e2a6be..bb9c1a30 100644 --- a/src/utils/node-graphs/services-node-graph.ts +++ b/src/utils/node-graphs/services-node-graph.ts @@ -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; @@ -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];