Skip to content

Commit

Permalink
Merge branch 'event-catalog:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
XaaXaaX authored Oct 20, 2024
2 parents d8d6653 + 4525464 commit f8a5caa
Show file tree
Hide file tree
Showing 68 changed files with 548 additions and 338 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @eventcatalog/core

## 2.9.1

### Patch Changes

- 5fa9228: fix(core): moving rimraf to dep of project

## 2.9.0

### Minor Changes

- 70d27a7: feat(core): support nested folder structures for domains, services and messages

## 2.8.12

### Patch Changes

- e7cb5d7: chore(core): added astro file path to resources

## 2.8.11

### Patch Changes
Expand Down
24 changes: 24 additions & 0 deletions examples/default/domains/Payment/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
id: Payment
name: Payment
version: 0.0.1
summary: |
Domain that contains payment related services and messages.
owners:
- dboyne
services:
- id: PaymentService
version: 0.0.1
badges:
- content: Payment Domain
backgroundColor: blue
textColor: blue
---

## Overview

The Payment Domain encompasses all services and components related to handling financial transactions within the system. It is responsible for managing payments, transactions, billing, and financial records. The domain ensures secure, reliable, and efficient processing of all payment-related activities

## Bounded context

<NodeGraph />
31 changes: 31 additions & 0 deletions examples/default/domains/Payment/services/PaymentService/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: PaymentService
name: Payment Service
version: 0.0.1
summary: |
Service that handles payments
owners:
- dboyne
receives:
- id: PaymentInitiated
version: 0.0.1
sends:
- id: PaymentProcessed
version: 0.0.1
repository:
language: JavaScript
url: https://github.com/boyney123/pretend-shipping-service
---

The Payment Service is a crucial component of our system that handles all payment-related operations. It processes payments, manages transactions, and communicates with other services through events. Using an event-driven architecture, it ensures that all actions are asynchronous, decoupled, and scalable.

<NodeGraph />

### Key Components
- Payment API: Exposes endpoints for initiating payments and querying payment status.
- Payment Processor: Handles the core payment processing logic.
- Event Bus: Manages the communication between services using events.
- Payment Gateway: Interfaces with external payment providers.
- Transaction Service: Manages transaction records and states.
- Notification Service: Sends notifications related to payment status changes.
- Database: Stores transaction data and payment status.
24 changes: 24 additions & 0 deletions examples/default/domains/Subscriptions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
id: Subscription
name: Subscription
version: 0.0.1
summary: |
Domain that contains subscription related services and messages.
owners:
- dboyne
services:
- id: SubscriptionService
version: 0.0.1
badges:
- content: Payment Domain
backgroundColor: blue
textColor: blue
---

## Overview

The Payment Domain encompasses all services and components related to handling financial transactions within the system. It is responsible for managing payments, transactions, billing, and financial records. The domain ensures secure, reliable, and efficient processing of all payment-related activities

## Bounded context

<NodeGraph />
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ owners:
receives:
- id: SubscribeUser
version: 0.0.1
- id: CancelSubscription
version: 0.0.1
sends:
- id: UserSubscriptionStarted
- id: UserSubscriptionStarted
version: 0.0.1
- id: UserSubscriptionCancelled
version: 0.0.1
repository:
language: JavaScript
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/event-catalog/eventcatalog.git"
},
"type": "module",
"version": "2.8.11",
"version": "2.9.1",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -79,7 +79,8 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"unist-util-visit": "^5.0.0",
"uuid": "^10.0.0"
"uuid": "^10.0.0",
"rimraf": "^5.0.7"
},
"devDependencies": {
"@changesets/cli": "^2.27.5",
Expand All @@ -88,7 +89,6 @@
"@types/react-dom": "^18.3.0",
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.1",
"rimraf": "^5.0.7",
"tsup": "^8.1.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.5"
Expand Down
95 changes: 61 additions & 34 deletions scripts/__tests__/catalog-to-astro-content-directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,56 @@ import { existsSync } from 'fs';
// import * as fs from 'fs-extra';

const TMP_DIRECTORY = path.join(__dirname, 'tmp');
const ASTRO_OUTPUT = path.join(TMP_DIRECTORY, 'content');
const ASTRO_OUTPUT = path.join(TMP_DIRECTORY);
const ASTRO_CONTENT_DIRECTORY = path.join(TMP_DIRECTORY, 'src', 'content');
// const OUTPUT_EXTERNAL_FILES = path.join(TMP_DIRECTORY, 'catalog-files');
const CATALOG_DIR = path.join(__dirname, 'example-catalog');
const CATALOG_FILES_DIR = path.join(TMP_DIRECTORY, 'catalog-files');
const CATALOG_FILES_DIR = path.join(TMP_DIRECTORY, 'src/catalog-files');

import { expect, describe, it, beforeAll, afterAll } from 'vitest';

describe('catalog-to-astro-content-directory', () => {
beforeAll(async () => {
await fs.mkdir(TMP_DIRECTORY, { recursive: true });
await fs.mkdir(ASTRO_OUTPUT, { recursive: true });
await fs.writeFile(path.join(ASTRO_OUTPUT, 'config.ts'), 'export const config = {};');
// create src/content inside astro directory
await fs.mkdir(ASTRO_CONTENT_DIRECTORY, { recursive: true });
await fs.writeFile(path.join(ASTRO_CONTENT_DIRECTORY, 'config.ts'), 'export const config = {};');

// console.log(path.join(ASTRO_OUTPUT, 'config.ts'))

// Convert the catalog
await catalogToAstro(CATALOG_DIR, ASTRO_OUTPUT, CATALOG_FILES_DIR);
await catalogToAstro(CATALOG_DIR, ASTRO_OUTPUT);
});

afterAll(async () => {
await fs.rm(TMP_DIRECTORY, { recursive: true });
await fs.rm(path.join(__dirname, 'public'), { recursive: true });
// await fs.rm(path.join(__dirname, 'public'), { recursive: true });
const defaultFile = await fs.readFile(path.join(CATALOG_DIR, 'eventcatalog.config.defaults.js'), 'utf8');
await fs.writeFile(path.join(CATALOG_DIR, 'eventcatalog.config.js'), defaultFile);
});

describe('events', () => {
describe('/events directory', () => {
it('takes events from the users catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory/InventoryAdjusted'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory/InventoryAdjusted/versioned/0.0.1'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory/InventoryAdjusted/versioned/1.0.0'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Order'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Order/OrderAmended', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory/InventoryAdjusted'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory/InventoryAdjusted/versioned/0.0.1'))).toBe(
true
);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory/InventoryAdjusted/versioned/1.0.0'))).toBe(
true
);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Order'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Order/OrderAmended', 'index.mdx'))).toBe(true);
});
it('when an event is versioned it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory/InventoryAdjusted/versioned/0.0.1'))).toBe(true);
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'Inventory/InventoryAdjusted/versioned/1.0.0'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory/InventoryAdjusted/versioned/0.0.1'))).toBe(
true
);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'Inventory/InventoryAdjusted/versioned/1.0.0'))).toBe(
true
);
});

it('when an event has a schema file along side it, that is copied to the correct location', async () => {
Expand All @@ -57,11 +70,13 @@ describe('catalog-to-astro-content-directory', () => {

describe('events within the /services directory', () => {
it('when an event is inside a service folder it copies the event into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'PaymentAccepted', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'PaymentAccepted', 'index.mdx'))).toBe(true);
});

it('when an event is versioned and it is within the service directory it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'PaymentAccepted', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'PaymentAccepted', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});

it('when an event has a schema file along side it, that is copied to the correct location', async () => {
Expand All @@ -71,7 +86,7 @@ describe('catalog-to-astro-content-directory', () => {

describe('events within the /domain directory', () => {
it('when an event is inside a domain folder it copies the event into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'events', 'PaymentDomainTestEvent1', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'events', 'PaymentDomainTestEvent1', 'index.mdx'))).toBe(true);
});

it('when an event has a schema file along side it, that is copied to the correct location', async () => {
Expand All @@ -83,10 +98,12 @@ describe('catalog-to-astro-content-directory', () => {
describe('commands', () => {
describe('/commands directory', () => {
it('takes an command from the users catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'commands', 'AddInventory', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'commands', 'AddInventory', 'index.mdx'))).toBe(true);
});
it('when an command is versioned it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'commands', 'AddInventory', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'commands', 'AddInventory', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});

it('when an command has a schema file along side it, that is copied to the correct location', async () => {
Expand All @@ -104,11 +121,13 @@ describe('catalog-to-astro-content-directory', () => {
describe('services', () => {
describe('/services directory', () => {
it('takes services from the users catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'services', 'PaymentService', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'services', 'PaymentService', 'index.mdx'))).toBe(true);
});

it('when a service is versioned it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'services', 'PaymentService', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'services', 'PaymentService', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});

it('when a service has a file within its directory (not markdown file, e.g AsyncAPI), it copies this version into the correct location', async () => {
Expand All @@ -117,13 +136,13 @@ describe('catalog-to-astro-content-directory', () => {
});
describe('services within the /domains directory', () => {
it('takes services from the users catalog (which are in a domains folder) and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'services', 'ExternalPaymentService', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'services', 'ExternalPaymentService', 'index.mdx'))).toBe(true);
});

it('when a service is versioned (within a domain folder) it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'services', 'ExternalPaymentService', 'versioned', '0.0.1', 'index.mdx'))).toBe(
true
);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'services', 'ExternalPaymentService', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});

it('when a service has a file within its directory (not markdown file, e.g AsyncAPI), it copies this version into the correct location', async () => {
Expand All @@ -135,11 +154,13 @@ describe('catalog-to-astro-content-directory', () => {
describe('domains', () => {
describe('/domain directory', () => {
it('takes domains from the domains catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'domains', 'Payment', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'domains', 'Payment', 'index.mdx'))).toBe(true);
});

it('when a domain is versioned it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'domains', 'Payment', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'domains', 'Payment', 'versioned', '0.0.1', 'index.mdx'))).toBe(
true
);
});

it('when a domain has a file within its directory (not markdown file, e.g AsyncAPI), it copies this version into the correct location', async () => {
Expand All @@ -151,45 +172,51 @@ describe('catalog-to-astro-content-directory', () => {
describe('flows', () => {
describe('/flows directory', () => {
it('takes flows from the users catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'flows', 'Payment', 'PaymentProcessed', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'Payment', 'PaymentProcessed', 'index.mdx'))).toBe(true);
});

it('when a flow is versioned it copies this version into the correct location', async () => {
expect(
existsSync(path.join(ASTRO_OUTPUT, 'flows', 'Payment', 'PaymentProcessed', 'versioned', '0.0.1', 'index.mdx'))
existsSync(
path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'Payment', 'PaymentProcessed', 'versioned', '0.0.1', 'index.mdx')
)
).toBe(true);
});
});
describe('flows within the /services directory', () => {
it('takes flows from the users catalog (which are in a services folder) and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'flows', 'PaymentAccepted', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'PaymentAccepted', 'index.mdx'))).toBe(true);
});

it('when a flow is versioned (within a services folder) it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'flows', 'PaymentAccepted', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'PaymentAccepted', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});
});

describe('flows within the /domains directory', () => {
it('takes flows from the users catalog (which are in a domains folder) and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'flows', 'ProcessingOfAnOrder', 'index.mdx'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'ProcessingOfAnOrder', 'index.mdx'))).toBe(true);
});

it('when a flow is versioned (within a domains folder) it copies this version into the correct location', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'flows', 'ProcessingOfAnOrder', 'versioned', '0.0.1', 'index.mdx'))).toBe(true);
expect(
existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'flows', 'ProcessingOfAnOrder', 'versioned', '0.0.1', 'index.mdx'))
).toBe(true);
});
});
});

describe('users', () => {
it('takes users from the catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'users', 'dboyne.md'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'users', 'dboyne.md'))).toBe(true);
});
});

describe('teams', () => {
it('takes teams from the catalog and puts it into the expected directory structure', async () => {
expect(existsSync(path.join(ASTRO_OUTPUT, 'teams', 'full-stack.md'))).toBe(true);
expect(existsSync(path.join(ASTRO_CONTENT_DIRECTORY, 'teams', 'full-stack.md'))).toBe(true);
});
});

Expand Down
Loading

0 comments on commit f8a5caa

Please sign in to comment.