@eventcatalog/create-eventcatalog 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22962 -1
- package/package.json +26 -50
- package/templates/default/Dockerfile +11 -0
- package/templates/default/README-template.md +1 -0
- package/templates/default/commands/AddInventory/index.md +42 -0
- package/templates/default/commands/AddInventory/schema.json +29 -0
- package/templates/default/commands/UpdateInventory/index.md +42 -0
- package/templates/default/commands/UpdateInventory/schema.json +29 -0
- package/templates/default/domains/Orders/index.md +49 -0
- package/templates/default/domains/Orders/versioned/0.0.1/index.md +20 -0
- package/templates/default/domains/Payment/index.md +24 -0
- package/templates/default/eventcatalog.config.js +18 -0
- package/templates/default/eventcatalog.styles.css +1 -0
- package/templates/default/events/Inventory/InventoryAdjusted/index.md +103 -0
- package/templates/default/events/Inventory/InventoryAdjusted/schema.avro +13 -0
- package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md +19 -0
- package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro +9 -0
- package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.3/index.md +104 -0
- package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.3/schema.avro +14 -0
- package/templates/default/events/Inventory/OutOfStock/index.md +96 -0
- package/templates/default/events/Order/OrderAmended/index.md +53 -0
- package/templates/default/events/Order/OrderAmended/schema.avro +75 -0
- package/templates/default/events/Order/OrderAmended/schema.json +71 -0
- package/templates/default/events/Order/OrderCancelled/index.md +51 -0
- package/templates/default/events/Order/OrderCancelled/schema.json +72 -0
- package/templates/default/events/Order/OrderConfirmed/index.md +51 -0
- package/templates/default/events/Order/OrderConfirmed/schema.json +67 -0
- package/templates/default/events/Payment/PaymentInitiated/index.md +32 -0
- package/templates/default/events/Payment/PaymentProcessed/index.md +38 -0
- package/{dist → templates}/default/gitignore +2 -2
- package/templates/default/services/InventoryService/index.md +36 -0
- package/templates/default/services/NotificationService/index.md +36 -0
- package/templates/default/services/OrdersService/index.md +29 -0
- package/templates/default/services/OrdersService/openapi.yml +170 -0
- package/templates/default/services/PaymentService/index.md +31 -0
- package/templates/default/teams/full-stack.md +26 -0
- package/templates/default/teams/mobile-devs.md +20 -0
- package/templates/default/users/aSmith.md +27 -0
- package/templates/default/users/dboyne.md +32 -0
- package/templates/default/users/mSmith.md +8 -0
- package/templates/index.ts +137 -0
- package/templates/types.ts +21 -0
- package/dist/default/Dockerfile +0 -20
- package/dist/default/README-template.md +0 -1
- package/dist/default/dockerignore +0 -7
- package/dist/default/domains/Shopping/events/AddedItemToCart/examples/example.js +0 -17
- package/dist/default/domains/Shopping/events/AddedItemToCart/index.md +0 -29
- package/dist/default/domains/Shopping/events/AddedItemToCart/schema.json +0 -46
- package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.1/index.md +0 -28
- package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.1/schema.json +0 -39
- package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.2/index.md +0 -28
- package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.2/schema.json +0 -46
- package/dist/default/domains/Shopping/events/RemovedItemFromCart/index.md +0 -26
- package/dist/default/domains/Shopping/events/RemovedItemFromCart/schema.json +0 -46
- package/dist/default/domains/Shopping/index.md +0 -16
- package/dist/default/eventcatalog.config.js +0 -50
- package/dist/default/eventcatalog.styles.css +0 -15
- package/dist/default/events/OrderComplete/index.md +0 -23
- package/dist/default/events/OrderComplete/schema.json +0 -39
- package/dist/default/events/OrderConfirmed/index.md +0 -23
- package/dist/default/events/OrderConfirmed/schema.json +0 -39
- package/dist/default/events/OrderRequested/index.md +0 -25
- package/dist/default/events/OrderRequested/schema.json +0 -39
- package/dist/default/events/PaymentProcessed/index.md +0 -25
- package/dist/default/events/PaymentProcessed/schema.json +0 -43
- package/dist/default/events/ShipmentDelivered/index.md +0 -24
- package/dist/default/events/ShipmentDelivered/schema.json +0 -43
- package/dist/default/events/ShipmentDispatched/index.md +0 -23
- package/dist/default/events/ShipmentDispatched/schema.json +0 -43
- package/dist/default/events/ShipmentPrepared/index.md +0 -23
- package/dist/default/events/ShipmentPrepared/schema.json +0 -43
- package/dist/default/public/favicon.ico +0 -0
- package/dist/default/public/logo.svg +0 -44
- package/dist/default/public/opengraph.png +0 -0
- package/dist/default/services/Basket Service/index.md +0 -16
- package/dist/default/services/Data Lake/index.md +0 -11
- package/dist/default/services/Payment Service/index.md +0 -15
- package/dist/default/services/Payment Service/openapi.yaml +0 -94
- package/dist/default/services/Shipping Service/index.md +0 -16
- package/dist/gitignore +0 -24
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: OutOfStock
|
|
3
|
+
name: Inventory out of stock
|
|
4
|
+
version: 0.0.3
|
|
5
|
+
summary: |
|
|
6
|
+
Indicates inventory is out of stock
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- msmith
|
|
10
|
+
- asmith
|
|
11
|
+
- full-stack
|
|
12
|
+
- mobile-devs
|
|
13
|
+
badges:
|
|
14
|
+
- content: Recently updated!
|
|
15
|
+
backgroundColor: green
|
|
16
|
+
textColor: green
|
|
17
|
+
- content: Channel:Apache Kafka
|
|
18
|
+
backgroundColor: yellow
|
|
19
|
+
textColor: yellow
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
The `Inventory Adjusted` event is triggered whenever there is a change in the inventory levels of a product. This could occur due to various reasons such as receiving new stock, sales, returns, or manual adjustments by the inventory management team. The event ensures that all parts of the system that rely on inventory data are kept up-to-date with the latest inventory levels.
|
|
25
|
+
|
|
26
|
+
<NodeGraph />
|
|
27
|
+
|
|
28
|
+
### Payload
|
|
29
|
+
The payload of the `Inventory Adjusted` event includes the following fields:
|
|
30
|
+
|
|
31
|
+
```json title="Example of payload" frame="terminal"
|
|
32
|
+
{
|
|
33
|
+
"event_id": "string",
|
|
34
|
+
"timestamp": "ISO 8601 date-time",
|
|
35
|
+
"product_id": "string",
|
|
36
|
+
"adjusted_quantity": "integer",
|
|
37
|
+
"new_quantity": "integer",
|
|
38
|
+
"adjustment_reason": "string",
|
|
39
|
+
"adjusted_by": "string"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Producing the Event
|
|
44
|
+
|
|
45
|
+
To produce an Inventory Adjusted event, use the following example Kafka producer configuration in Python:
|
|
46
|
+
|
|
47
|
+
```python title="Produce event in Python" frame="terminal"
|
|
48
|
+
from kafka import KafkaProducer
|
|
49
|
+
import json
|
|
50
|
+
from datetime import datetime
|
|
51
|
+
|
|
52
|
+
# Kafka configuration
|
|
53
|
+
producer = KafkaProducer(
|
|
54
|
+
bootstrap_servers=['localhost:9092'],
|
|
55
|
+
value_serializer=lambda v: json.dumps(v).encode('utf-8')
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Event data
|
|
59
|
+
event_data = {
|
|
60
|
+
"event_id": "abc123",
|
|
61
|
+
"timestamp": datetime.utcnow().isoformat() + 'Z',
|
|
62
|
+
"product_id": "prod987",
|
|
63
|
+
"adjusted_quantity": 10,
|
|
64
|
+
"new_quantity": 150,
|
|
65
|
+
"adjustment_reason": "restock",
|
|
66
|
+
"adjusted_by": "user123"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Send event to Kafka topic
|
|
70
|
+
producer.send('inventory.adjusted', event_data)
|
|
71
|
+
producer.flush()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Consuming the Event
|
|
75
|
+
|
|
76
|
+
To consume an Inventory Adjusted event, use the following example Kafka consumer configuration in Python:
|
|
77
|
+
|
|
78
|
+
```python title="Consuming the event with python" frame="terminal"
|
|
79
|
+
from kafka import KafkaConsumer
|
|
80
|
+
import json
|
|
81
|
+
|
|
82
|
+
# Kafka configuration
|
|
83
|
+
consumer = KafkaConsumer(
|
|
84
|
+
'inventory.adjusted',
|
|
85
|
+
bootstrap_servers=['localhost:9092'],
|
|
86
|
+
auto_offset_reset='earliest',
|
|
87
|
+
enable_auto_commit=True,
|
|
88
|
+
group_id='inventory_group',
|
|
89
|
+
value_serializer=lambda v: json.dumps(v).encode('utf-8')
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Consume events
|
|
93
|
+
for message in consumer:
|
|
94
|
+
event_data = json.loads(message.value)
|
|
95
|
+
print(f"Received Inventory Adjusted event: {event_data}")
|
|
96
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: OrderAmended
|
|
3
|
+
name: Order amended
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: |
|
|
6
|
+
Indicates an order has been changed
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- msmith
|
|
10
|
+
badges:
|
|
11
|
+
- content: Recently updated!
|
|
12
|
+
backgroundColor: green
|
|
13
|
+
textColor: green
|
|
14
|
+
- content: Channel:Apache Kafka
|
|
15
|
+
backgroundColor: yellow
|
|
16
|
+
textColor: yellow
|
|
17
|
+
schemaPath: schema.avro
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
The OrderAmended event is triggered whenever an existing order is modified. This event ensures that all relevant services are notified of changes to an order, such as updates to order items, quantities, shipping information, or status. The event allows the system to maintain consistency and ensure that all dependent services can react appropriately to the amendments.
|
|
23
|
+
|
|
24
|
+
## Example payload
|
|
25
|
+
|
|
26
|
+
```json title="Example Payload"
|
|
27
|
+
{
|
|
28
|
+
"orderId": "123e4567-e89b-12d3-a456-426614174000",
|
|
29
|
+
"userId": "123e4567-e89b-12d3-a456-426614174000",
|
|
30
|
+
"amendedItems": [
|
|
31
|
+
{
|
|
32
|
+
"productId": "789e1234-b56c-78d9-e012-3456789fghij",
|
|
33
|
+
"productName": "Example Product",
|
|
34
|
+
"oldQuantity": 2,
|
|
35
|
+
"newQuantity": 3,
|
|
36
|
+
"unitPrice": 29.99,
|
|
37
|
+
"totalPrice": 89.97
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"orderStatus": "confirmed",
|
|
41
|
+
"totalAmount": 150.75,
|
|
42
|
+
"timestamp": "2024-07-04T14:48:00Z"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Schema (Avro)
|
|
47
|
+
|
|
48
|
+
<Schema file="schema.avro" />
|
|
49
|
+
|
|
50
|
+
## Schema (JSON)
|
|
51
|
+
|
|
52
|
+
<Schema file="schema.json" />
|
|
53
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "record",
|
|
3
|
+
"name": "OrderAmendedEvent",
|
|
4
|
+
"namespace": "com.example.events",
|
|
5
|
+
"fields": [
|
|
6
|
+
{
|
|
7
|
+
"name": "orderId",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"doc": "The unique identifier of the order that was amended."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "userId",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"doc": "The unique identifier of the user who placed the order."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "amendedItems",
|
|
18
|
+
"type": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"items": {
|
|
21
|
+
"type": "record",
|
|
22
|
+
"name": "AmendedItem",
|
|
23
|
+
"fields": [
|
|
24
|
+
{
|
|
25
|
+
"name": "productId",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"doc": "The unique identifier of the product."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "productName",
|
|
31
|
+
"type": "string",
|
|
32
|
+
"doc": "The name of the product."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "oldQuantity",
|
|
36
|
+
"type": "int",
|
|
37
|
+
"doc": "The original quantity of the product ordered."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "newQuantity",
|
|
41
|
+
"type": "int",
|
|
42
|
+
"doc": "The new quantity of the product ordered."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "unitPrice",
|
|
46
|
+
"type": "double",
|
|
47
|
+
"doc": "The price per unit of the product."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "totalPrice",
|
|
51
|
+
"type": "double",
|
|
52
|
+
"doc": "The total price for this order item (newQuantity * unitPrice)."
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"doc": "A list of items that were amended in the order, each containing product details and updated quantities."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "orderStatus",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"doc": "The current status of the order after the amendment."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "totalAmount",
|
|
66
|
+
"type": "double",
|
|
67
|
+
"doc": "The total amount of the order after the amendment."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "timestamp",
|
|
71
|
+
"type": "string",
|
|
72
|
+
"doc": "The date and time when the order was amended, in ISO 8601 format."
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "OrderAmendedEvent",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"orderId": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "uuid",
|
|
9
|
+
"description": "The unique identifier of the order that was amended."
|
|
10
|
+
},
|
|
11
|
+
"userId": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"format": "uuid",
|
|
14
|
+
"description": "The unique identifier of the user who placed the order."
|
|
15
|
+
},
|
|
16
|
+
"amendedItems": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "A list of items that were amended in the order, each containing product details and updated quantities.",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"productId": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "uuid",
|
|
25
|
+
"description": "The unique identifier of the product."
|
|
26
|
+
},
|
|
27
|
+
"productName": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The name of the product."
|
|
30
|
+
},
|
|
31
|
+
"oldQuantity": {
|
|
32
|
+
"type": "integer",
|
|
33
|
+
"description": "The original quantity of the product ordered."
|
|
34
|
+
},
|
|
35
|
+
"newQuantity": {
|
|
36
|
+
"type": "integer",
|
|
37
|
+
"description": "The new quantity of the product ordered."
|
|
38
|
+
},
|
|
39
|
+
"unitPrice": {
|
|
40
|
+
"type": "number",
|
|
41
|
+
"format": "float",
|
|
42
|
+
"description": "The price per unit of the product."
|
|
43
|
+
},
|
|
44
|
+
"totalPrice": {
|
|
45
|
+
"type": "number",
|
|
46
|
+
"format": "float",
|
|
47
|
+
"description": "The total price for this order item (newQuantity * unitPrice)."
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": ["productId", "productName", "oldQuantity", "newQuantity", "unitPrice", "totalPrice"]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"orderStatus": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "The current status of the order after the amendment."
|
|
56
|
+
},
|
|
57
|
+
"totalAmount": {
|
|
58
|
+
"type": "number",
|
|
59
|
+
"format": "float",
|
|
60
|
+
"description": "The total amount of the order after the amendment."
|
|
61
|
+
},
|
|
62
|
+
"timestamp": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"format": "date-time",
|
|
65
|
+
"description": "The date and time when the order was amended, in ISO 8601 format."
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"required": ["orderId", "userId", "amendedItems", "orderStatus", "totalAmount", "timestamp"],
|
|
69
|
+
"additionalProperties": false
|
|
70
|
+
}
|
|
71
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: OrderCancelled
|
|
3
|
+
name: Order cancelled
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: |
|
|
6
|
+
Indicates an order has been canceled
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- msmith
|
|
10
|
+
badges:
|
|
11
|
+
- content: Recently updated!
|
|
12
|
+
backgroundColor: green
|
|
13
|
+
textColor: green
|
|
14
|
+
- content: Channel:Apache Kafka
|
|
15
|
+
backgroundColor: yellow
|
|
16
|
+
textColor: yellow
|
|
17
|
+
schemaPath: 'schema.json'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
The OrderCancelled event is triggered whenever an existing order is cancelled. This event ensures that all relevant services are notified of the cancellation, allowing them to take appropriate actions such as updating inventory levels, refunding payments, and notifying the user. The event helps maintain consistency across the system by ensuring all dependent services are aware of the order cancellation.
|
|
23
|
+
|
|
24
|
+
## Example payload
|
|
25
|
+
|
|
26
|
+
```json title="Example payload"
|
|
27
|
+
{
|
|
28
|
+
"orderId": "123e4567-e89b-12d3-a456-426614174000",
|
|
29
|
+
"userId": "123e4567-e89b-12d3-a456-426614174000",
|
|
30
|
+
"orderItems": [
|
|
31
|
+
{
|
|
32
|
+
"productId": "789e1234-b56c-78d9-e012-3456789fghij",
|
|
33
|
+
"productName": "Example Product",
|
|
34
|
+
"quantity": 2,
|
|
35
|
+
"unitPrice": 29.99,
|
|
36
|
+
"totalPrice": 59.98
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"orderStatus": "cancelled",
|
|
40
|
+
"totalAmount": 59.98,
|
|
41
|
+
"cancellationReason": "Customer requested cancellation",
|
|
42
|
+
"timestamp": "2024-07-04T14:48:00Z"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Schema
|
|
48
|
+
|
|
49
|
+
JSON schema for the event.
|
|
50
|
+
|
|
51
|
+
<Schema title="JSON Schema" file="schema.json"/>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "OrderCancelledEvent",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"orderId": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "uuid",
|
|
9
|
+
"description": "The unique identifier of the order that was cancelled."
|
|
10
|
+
},
|
|
11
|
+
"userId": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"format": "uuid",
|
|
14
|
+
"description": "The unique identifier of the user who placed the order."
|
|
15
|
+
},
|
|
16
|
+
"orderItems": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "A list of items included in the cancelled order, each containing product details and quantities.",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"productId": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "uuid",
|
|
25
|
+
"description": "The unique identifier of the product."
|
|
26
|
+
},
|
|
27
|
+
"productName": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The name of the product."
|
|
30
|
+
},
|
|
31
|
+
"quantity": {
|
|
32
|
+
"type": "integer",
|
|
33
|
+
"description": "The quantity of the product ordered."
|
|
34
|
+
},
|
|
35
|
+
"unitPrice": {
|
|
36
|
+
"type": "number",
|
|
37
|
+
"format": "float",
|
|
38
|
+
"description": "The price per unit of the product."
|
|
39
|
+
},
|
|
40
|
+
"totalPrice": {
|
|
41
|
+
"type": "number",
|
|
42
|
+
"format": "float",
|
|
43
|
+
"description": "The total price for this order item (quantity * unit price)."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": ["productId", "productName", "quantity", "unitPrice", "totalPrice"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"orderStatus": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "The current status of the order after cancellation.",
|
|
52
|
+
"enum": ["cancelled"]
|
|
53
|
+
},
|
|
54
|
+
"totalAmount": {
|
|
55
|
+
"type": "number",
|
|
56
|
+
"format": "float",
|
|
57
|
+
"description": "The total amount of the order that was cancelled."
|
|
58
|
+
},
|
|
59
|
+
"cancellationReason": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "The reason for the order cancellation, if provided."
|
|
62
|
+
},
|
|
63
|
+
"timestamp": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"format": "date-time",
|
|
66
|
+
"description": "The date and time when the order was cancelled."
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": ["orderId", "userId", "orderItems", "orderStatus", "totalAmount", "timestamp"],
|
|
70
|
+
"additionalProperties": false
|
|
71
|
+
}
|
|
72
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: OrderConfirmed
|
|
3
|
+
name: Order confirmed
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: |
|
|
6
|
+
Indicates an order has been confirmed
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- msmith
|
|
10
|
+
badges:
|
|
11
|
+
- content: Recently updated!
|
|
12
|
+
backgroundColor: green
|
|
13
|
+
textColor: green
|
|
14
|
+
- content: Channel:Apache Kafka
|
|
15
|
+
backgroundColor: yellow
|
|
16
|
+
textColor: yellow
|
|
17
|
+
schemaPath: schema.json
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
The OrderConfirmed event is triggered when an order has been successfully confirmed. This event notifies relevant services that the order is ready for further processing, such as inventory adjustment, payment finalization, and preparation for shipping.
|
|
23
|
+
|
|
24
|
+
## Architecture Diagram
|
|
25
|
+
|
|
26
|
+
<NodeGraph />
|
|
27
|
+
|
|
28
|
+
## Payload
|
|
29
|
+
|
|
30
|
+
```json title="Example payload"
|
|
31
|
+
{
|
|
32
|
+
"orderId": "123e4567-e89b-12d3-a456-426614174000",
|
|
33
|
+
"userId": "123e4567-e89b-12d3-a456-426614174000",
|
|
34
|
+
"orderItems": [
|
|
35
|
+
{
|
|
36
|
+
"productId": "789e1234-b56c-78d9-e012-3456789fghij",
|
|
37
|
+
"productName": "Example Product",
|
|
38
|
+
"quantity": 2,
|
|
39
|
+
"unitPrice": 29.99,
|
|
40
|
+
"totalPrice": 59.98
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"orderStatus": "confirmed",
|
|
44
|
+
"totalAmount": 150.75,
|
|
45
|
+
"confirmationTimestamp": "2024-07-04T14:48:00Z"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Schema
|
|
50
|
+
|
|
51
|
+
<Schema file="schema.json"/>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "OrderConfirmedEvent",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"orderId": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "uuid",
|
|
9
|
+
"description": "The unique identifier of the confirmed order."
|
|
10
|
+
},
|
|
11
|
+
"userId": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"format": "uuid",
|
|
14
|
+
"description": "The unique identifier of the user who placed the order."
|
|
15
|
+
},
|
|
16
|
+
"orderItems": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "A list of items included in the confirmed order, each containing product details and quantities.",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"productId": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "uuid",
|
|
25
|
+
"description": "The unique identifier of the product."
|
|
26
|
+
},
|
|
27
|
+
"productName": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The name of the product."
|
|
30
|
+
},
|
|
31
|
+
"quantity": {
|
|
32
|
+
"type": "integer",
|
|
33
|
+
"description": "The quantity of the product ordered."
|
|
34
|
+
},
|
|
35
|
+
"unitPrice": {
|
|
36
|
+
"type": "number",
|
|
37
|
+
"format": "float",
|
|
38
|
+
"description": "The price per unit of the product."
|
|
39
|
+
},
|
|
40
|
+
"totalPrice": {
|
|
41
|
+
"type": "number",
|
|
42
|
+
"format": "float",
|
|
43
|
+
"description": "The total price for this order item (quantity * unitPrice)."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": ["productId", "productName", "quantity", "unitPrice", "totalPrice"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"orderStatus": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "The current status of the order after confirmation."
|
|
52
|
+
},
|
|
53
|
+
"totalAmount": {
|
|
54
|
+
"type": "number",
|
|
55
|
+
"format": "float",
|
|
56
|
+
"description": "The total amount of the confirmed order."
|
|
57
|
+
},
|
|
58
|
+
"confirmationTimestamp": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"format": "date-time",
|
|
61
|
+
"description": "The date and time when the order was confirmed."
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["orderId", "userId", "orderItems", "orderStatus", "totalAmount", "confirmationTimestamp"],
|
|
65
|
+
"additionalProperties": false
|
|
66
|
+
}
|
|
67
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PaymentInitiated
|
|
3
|
+
name: Payment Initiated
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: Event is triggered when a user initiates a payment through the Payment Service
|
|
6
|
+
owners:
|
|
7
|
+
- dboyne
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The Payment Initiated event is triggered when a user initiates a payment through the Payment Service. This event signifies the beginning of the payment process and contains all necessary information to process the payment.
|
|
13
|
+
|
|
14
|
+
<NodeGraph />
|
|
15
|
+
|
|
16
|
+
### Payload Example
|
|
17
|
+
|
|
18
|
+
```json title="Payload example"
|
|
19
|
+
{
|
|
20
|
+
"userId": "123e4567-e89b-12d3-a456-426614174000",
|
|
21
|
+
"orderId": "789e1234-b56c-78d9-e012-3456789fghij",
|
|
22
|
+
"amount": 100.50,
|
|
23
|
+
"paymentMethod": "CreditCard",
|
|
24
|
+
"timestamp": "2024-07-04T14:48:00Z"
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Security Considerations
|
|
29
|
+
|
|
30
|
+
- **Authentication**: Ensure that only authenticated users can initiate a payment, and the userId in the payload matches the authenticated user.
|
|
31
|
+
- **Data Validation**: Validate all input data to prevent injection attacks or other malicious input.
|
|
32
|
+
- **Sensitive Data Handling**: Avoid including sensitive information (e.g., credit card numbers) in the event payload. Use secure channels and encryption for such data.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PaymentProcessed
|
|
3
|
+
name: Payment Processed
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: Event is triggered after the payment has been successfully processed
|
|
6
|
+
owners:
|
|
7
|
+
- dboyne
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The PaymentProcessed event is triggered after the payment has been successfully processed by the Payment Service. This event signifies that a payment has been confirmed, and it communicates the outcome to other services and components within the system.
|
|
13
|
+
|
|
14
|
+
<NodeGraph />
|
|
15
|
+
|
|
16
|
+
### Payload Example
|
|
17
|
+
|
|
18
|
+
```json title="Payload example"
|
|
19
|
+
{
|
|
20
|
+
"transactionId": "123e4567-e89b-12d3-a456-426614174000",
|
|
21
|
+
"userId": "123e4567-e89b-12d3-a456-426614174000",
|
|
22
|
+
"orderId": "789e1234-b56c-78d9-e012-3456789fghij",
|
|
23
|
+
"amount": 100.50,
|
|
24
|
+
"paymentMethod": "CreditCard",
|
|
25
|
+
"status": "confirmed",
|
|
26
|
+
"confirmationDetails": {
|
|
27
|
+
"gatewayResponse": "Approved",
|
|
28
|
+
"transactionId": "abc123"
|
|
29
|
+
},
|
|
30
|
+
"timestamp": "2024-07-04T14:48:00Z"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Security Considerations
|
|
35
|
+
|
|
36
|
+
- **Data Validation**: Ensure that all data in the event payload is validated before publishing to prevent injection attacks or other malicious activities.
|
|
37
|
+
- **Sensitive Data Handling**: Avoid including sensitive information (e.g., full credit card numbers) in the event payload. Use secure channels and encryption for such data.
|
|
38
|
+
- **Authentication and Authorization**: Ensure that only authorized services can publish or consume PaymentProcessed events.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: InventoryService
|
|
3
|
+
version: 0.0.2
|
|
4
|
+
name: Inventory Service
|
|
5
|
+
summary: |
|
|
6
|
+
Service that handles the inventory
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- full-stack
|
|
10
|
+
- mobile-devs
|
|
11
|
+
receives:
|
|
12
|
+
- id: OrderConfirmed
|
|
13
|
+
version: 0.0.1
|
|
14
|
+
- id: OrderCancelled
|
|
15
|
+
version: 0.0.1
|
|
16
|
+
- id: OrderAmended
|
|
17
|
+
version: 0.0.1
|
|
18
|
+
- id: UpdateInventory
|
|
19
|
+
version: 0.0.3
|
|
20
|
+
sends:
|
|
21
|
+
- id: InventoryAdjusted
|
|
22
|
+
version: 0.0.4
|
|
23
|
+
- id: OutOfStock
|
|
24
|
+
version: 0.0.3
|
|
25
|
+
repository:
|
|
26
|
+
language: JavaScript
|
|
27
|
+
url: https://github.com/boyney123/pretend-shipping-service
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
The Inventory Service is a critical component of the system responsible for managing product stock levels, tracking inventory movements, and ensuring product availability. It interacts with other services to maintain accurate inventory records and supports operations such as order fulfillment, restocking, and inventory audits.
|
|
33
|
+
|
|
34
|
+
## Architecture diagram
|
|
35
|
+
|
|
36
|
+
<NodeGraph title="Hello world" />
|