@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.
Files changed (82) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +22962 -1
  4. package/package.json +26 -50
  5. package/templates/default/Dockerfile +11 -0
  6. package/templates/default/README-template.md +1 -0
  7. package/templates/default/commands/AddInventory/index.md +42 -0
  8. package/templates/default/commands/AddInventory/schema.json +29 -0
  9. package/templates/default/commands/UpdateInventory/index.md +42 -0
  10. package/templates/default/commands/UpdateInventory/schema.json +29 -0
  11. package/templates/default/domains/Orders/index.md +49 -0
  12. package/templates/default/domains/Orders/versioned/0.0.1/index.md +20 -0
  13. package/templates/default/domains/Payment/index.md +24 -0
  14. package/templates/default/eventcatalog.config.js +18 -0
  15. package/templates/default/eventcatalog.styles.css +1 -0
  16. package/templates/default/events/Inventory/InventoryAdjusted/index.md +103 -0
  17. package/templates/default/events/Inventory/InventoryAdjusted/schema.avro +13 -0
  18. package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md +19 -0
  19. package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro +9 -0
  20. package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.3/index.md +104 -0
  21. package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.3/schema.avro +14 -0
  22. package/templates/default/events/Inventory/OutOfStock/index.md +96 -0
  23. package/templates/default/events/Order/OrderAmended/index.md +53 -0
  24. package/templates/default/events/Order/OrderAmended/schema.avro +75 -0
  25. package/templates/default/events/Order/OrderAmended/schema.json +71 -0
  26. package/templates/default/events/Order/OrderCancelled/index.md +51 -0
  27. package/templates/default/events/Order/OrderCancelled/schema.json +72 -0
  28. package/templates/default/events/Order/OrderConfirmed/index.md +51 -0
  29. package/templates/default/events/Order/OrderConfirmed/schema.json +67 -0
  30. package/templates/default/events/Payment/PaymentInitiated/index.md +32 -0
  31. package/templates/default/events/Payment/PaymentProcessed/index.md +38 -0
  32. package/{dist → templates}/default/gitignore +2 -2
  33. package/templates/default/services/InventoryService/index.md +36 -0
  34. package/templates/default/services/NotificationService/index.md +36 -0
  35. package/templates/default/services/OrdersService/index.md +29 -0
  36. package/templates/default/services/OrdersService/openapi.yml +170 -0
  37. package/templates/default/services/PaymentService/index.md +31 -0
  38. package/templates/default/teams/full-stack.md +26 -0
  39. package/templates/default/teams/mobile-devs.md +20 -0
  40. package/templates/default/users/aSmith.md +27 -0
  41. package/templates/default/users/dboyne.md +32 -0
  42. package/templates/default/users/mSmith.md +8 -0
  43. package/templates/index.ts +137 -0
  44. package/templates/types.ts +21 -0
  45. package/dist/default/Dockerfile +0 -20
  46. package/dist/default/README-template.md +0 -1
  47. package/dist/default/dockerignore +0 -7
  48. package/dist/default/domains/Shopping/events/AddedItemToCart/examples/example.js +0 -17
  49. package/dist/default/domains/Shopping/events/AddedItemToCart/index.md +0 -29
  50. package/dist/default/domains/Shopping/events/AddedItemToCart/schema.json +0 -46
  51. package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.1/index.md +0 -28
  52. package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.1/schema.json +0 -39
  53. package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.2/index.md +0 -28
  54. package/dist/default/domains/Shopping/events/AddedItemToCart/versioned/0.0.2/schema.json +0 -46
  55. package/dist/default/domains/Shopping/events/RemovedItemFromCart/index.md +0 -26
  56. package/dist/default/domains/Shopping/events/RemovedItemFromCart/schema.json +0 -46
  57. package/dist/default/domains/Shopping/index.md +0 -16
  58. package/dist/default/eventcatalog.config.js +0 -50
  59. package/dist/default/eventcatalog.styles.css +0 -15
  60. package/dist/default/events/OrderComplete/index.md +0 -23
  61. package/dist/default/events/OrderComplete/schema.json +0 -39
  62. package/dist/default/events/OrderConfirmed/index.md +0 -23
  63. package/dist/default/events/OrderConfirmed/schema.json +0 -39
  64. package/dist/default/events/OrderRequested/index.md +0 -25
  65. package/dist/default/events/OrderRequested/schema.json +0 -39
  66. package/dist/default/events/PaymentProcessed/index.md +0 -25
  67. package/dist/default/events/PaymentProcessed/schema.json +0 -43
  68. package/dist/default/events/ShipmentDelivered/index.md +0 -24
  69. package/dist/default/events/ShipmentDelivered/schema.json +0 -43
  70. package/dist/default/events/ShipmentDispatched/index.md +0 -23
  71. package/dist/default/events/ShipmentDispatched/schema.json +0 -43
  72. package/dist/default/events/ShipmentPrepared/index.md +0 -23
  73. package/dist/default/events/ShipmentPrepared/schema.json +0 -43
  74. package/dist/default/public/favicon.ico +0 -0
  75. package/dist/default/public/logo.svg +0 -44
  76. package/dist/default/public/opengraph.png +0 -0
  77. package/dist/default/services/Basket Service/index.md +0 -16
  78. package/dist/default/services/Data Lake/index.md +0 -11
  79. package/dist/default/services/Payment Service/index.md +0 -15
  80. package/dist/default/services/Payment Service/openapi.yaml +0 -94
  81. package/dist/default/services/Shipping Service/index.md +0 -16
  82. package/dist/gitignore +0 -24
package/package.json CHANGED
@@ -1,76 +1,52 @@
1
1
  {
2
2
  "name": "@eventcatalog/create-eventcatalog",
3
- "version": "1.2.1",
4
- "keywords": [],
5
- "description": "Create event catalogs apps with one command",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/boyney123/eventcatalog"
9
- },
10
- "author": "David Boyne",
11
- "license": "MIT",
3
+ "description": "Create EventCatalog with one command",
4
+ "version": "2.0.0",
12
5
  "bin": {
13
- "create-eventcatalog2": "./dist/index.js"
6
+ "create-catalog": "./dist/index.js"
14
7
  },
15
8
  "files": [
16
- "dist"
9
+ "dist",
10
+ "templates"
17
11
  ],
18
12
  "publishConfig": {
19
13
  "access": "public"
20
14
  },
21
15
  "scripts": {
22
- "dev": "ncc build ./index.ts -w -o dist/",
23
- "test": "echo \"No test specified\"",
24
- "lint": "eslint --max-warnings 13 --config .eslintrc .",
25
- "prepare": "rimraf ./dist/ && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register",
26
- "build": "npm run prepare",
27
- "release": "semantic-release",
28
- "get:version": "echo $npm_package_version",
29
- "get:name": "echo $npm_package_name",
30
- "generate:assets": "echo \"No assets to generate so far\"",
31
- "bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION"
16
+ "prepublishOnly": "npm run build",
17
+ "build": "tsup index.ts --format cjs --dts",
18
+ "run": "node dist/index.js",
19
+ "dev": "npm run build --watch",
20
+ "changeset": "changeset",
21
+ "release": "changeset publish"
32
22
  },
33
23
  "devDependencies": {
34
- "@semantic-release/commit-analyzer": "^8.0.1",
35
- "@semantic-release/github": "^7.0.4",
36
- "@semantic-release/npm": "^7.0.6",
37
- "@semantic-release/release-notes-generator": "^9.0.1",
38
- "@types/async-retry": "1.3.0",
39
- "@types/cross-spawn": "^6.0.2",
24
+ "@types/async-retry": "1.4.2",
25
+ "@types/ci-info": "2.0.0",
26
+ "@types/cross-spawn": "6.0.0",
40
27
  "@types/node": "^12.6.8",
41
28
  "@types/prompts": "2.0.1",
42
29
  "@types/rimraf": "3.0.0",
43
30
  "@types/tar": "4.0.3",
44
31
  "@types/validate-npm-package-name": "3.0.0",
45
- "@typescript-eslint/eslint-plugin": "^6.3.0",
46
- "@typescript-eslint/parser": "^6.3.0",
47
- "@vercel/ncc": "0.25.1",
48
- "all-contributors-cli": "^6.14.2",
32
+ "@vercel/ncc": "0.34.0",
49
33
  "async-retry": "1.3.1",
50
34
  "chalk": "2.4.2",
35
+ "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
51
36
  "commander": "2.20.0",
52
- "conventional-changelog-conventionalcommits": "^4.4.0",
53
- "cpy": "7.3.0",
37
+ "cpy": "^11.0.0",
54
38
  "cross-spawn": "6.0.5",
55
- "eslint": "^8.46.0",
56
- "eslint-plugin-github": "^4.1.3",
57
- "eslint-plugin-security": "^1.4.0",
58
- "eslint-plugin-sonarjs": "^0.5.0",
59
- "got": "10.7.0",
60
- "jest": "^29.6.2",
61
- "jsdoc-to-markdown": "^5.0.0",
62
- "markdown-toc": "^1.2.0",
39
+ "fast-glob": "^3.3.2",
40
+ "got": "^14.0.0",
63
41
  "prompts": "2.1.0",
64
- "rimraf": "3.0.0",
65
- "semantic-release": "^17.2.2",
66
- "tar": "4.4.10",
67
- "typescript": "5.1.6",
68
- "unixify": "^1.0.0",
42
+ "rimraf": "^5.0.7",
43
+ "tar": "^4.4.19",
44
+ "tsup": "^8.1.0",
45
+ "typescript": "^5.4.5",
69
46
  "update-check": "1.5.4",
70
47
  "validate-npm-package-name": "3.0.0"
71
48
  },
72
- "engines": {
73
- "node": ">=12.0.0"
74
- },
75
- "gitHead": "5f82ce7f267e9b3ec771bbd3cc81359ed0a8fd18"
49
+ "dependencies": {
50
+ "@changesets/cli": "^2.27.6"
51
+ }
76
52
  }
@@ -0,0 +1,11 @@
1
+ FROM node:lts AS build
2
+ WORKDIR /app
3
+ COPY . .
4
+ # Fix for astro in docker https://github.com/withastro/astro/issues/2596
5
+ ENV NODE_OPTIONS=--max_old_space_size=2048
6
+ RUN npm i
7
+ RUN npm run build
8
+
9
+ FROM httpd:2.4 AS runtime
10
+ COPY --from=build /app/dist /usr/local/apache2/htdocs/
11
+ EXPOSE 80
@@ -0,0 +1 @@
1
+ # My Event Catalog
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: AddInventory
3
+ name: Add inventory
4
+ version: 0.0.3
5
+ summary: |
6
+ Command that will add item to a given inventory id
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
+ schemaPath: 'schema.json'
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ The AddInventory command is issued to add new stock to the inventory. This command is used by the inventory management system to update the quantity of products available in the warehouse or store.
23
+
24
+ ## Architecture diagram
25
+
26
+ <NodeGraph/>
27
+
28
+ ## Payload example
29
+
30
+ ```json title="Payload example"
31
+ {
32
+ "productId": "789e1234-b56c-78d9-e012-3456789fghij",
33
+ "quantity": 50,
34
+ "warehouseId": "456e7891-c23d-45f6-b78a-123456789abc",
35
+ "timestamp": "2024-07-04T14:48:00Z"
36
+ }
37
+
38
+ ```
39
+
40
+ ## Schema
41
+
42
+ <Schema file="schema.json"/>
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "AddInventoryCommand",
4
+ "type": "object",
5
+ "properties": {
6
+ "productId": {
7
+ "type": "string",
8
+ "format": "uuid",
9
+ "description": "The unique identifier of the product being added to the inventory."
10
+ },
11
+ "quantity": {
12
+ "type": "integer",
13
+ "description": "The quantity of the product being added to the inventory."
14
+ },
15
+ "warehouseId": {
16
+ "type": "string",
17
+ "format": "uuid",
18
+ "description": "The unique identifier of the warehouse where the inventory is being added."
19
+ },
20
+ "timestamp": {
21
+ "type": "string",
22
+ "format": "date-time",
23
+ "description": "The date and time when the inventory was added."
24
+ }
25
+ },
26
+ "required": ["productId", "quantity", "warehouseId", "timestamp"],
27
+ "additionalProperties": false
28
+ }
29
+
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: UpdateInventory
3
+ name: Update inventory
4
+ version: 0.0.3
5
+ summary: |
6
+ Command that will update a given inventory item
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
+ schemaPath: "schema.json"
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ The UpdateInventory command is issued to update the existing stock levels of a product in the inventory. This command is used by the inventory management system to adjust the quantity of products available in the warehouse or store, either by increasing or decreasing the current stock levels.
23
+
24
+ ## Architecture diagram
25
+
26
+ <NodeGraph />
27
+
28
+ ## Payload example
29
+
30
+ ```json title="Payload example"
31
+ {
32
+ "productId": "789e1234-b56c-78d9-e012-3456789fghij",
33
+ "quantityChange": -10,
34
+ "warehouseId": "456e7891-c23d-45f6-b78a-123456789abc",
35
+ "timestamp": "2024-07-04T14:48:00Z"
36
+ }
37
+ ```
38
+
39
+ ## Schema (JSON schema)
40
+
41
+ <Schema file="schema.json"/>
42
+
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "UpdateInventoryCommand",
4
+ "type": "object",
5
+ "properties": {
6
+ "productId": {
7
+ "type": "string",
8
+ "format": "uuid",
9
+ "description": "The unique identifier of the product whose inventory is being updated."
10
+ },
11
+ "quantityChange": {
12
+ "type": "integer",
13
+ "description": "The change in quantity of the product in the inventory. Positive values indicate an increase, while negative values indicate a decrease."
14
+ },
15
+ "warehouseId": {
16
+ "type": "string",
17
+ "format": "uuid",
18
+ "description": "The unique identifier of the warehouse where the inventory is being updated."
19
+ },
20
+ "timestamp": {
21
+ "type": "string",
22
+ "format": "date-time",
23
+ "description": "The date and time when the inventory update occurred."
24
+ }
25
+ },
26
+ "required": ["productId", "quantityChange", "warehouseId", "timestamp"],
27
+ "additionalProperties": false
28
+ }
29
+
@@ -0,0 +1,49 @@
1
+ ---
2
+ id: Orders
3
+ name: Orders
4
+ version: 0.0.2
5
+ owners:
6
+ - dboyne
7
+ services:
8
+ - id: InventoryService
9
+ version: 0.0.2
10
+ - id: NotificationService
11
+ version: 0.0.2
12
+ - id: OrdersService
13
+ version: 0.0.2
14
+ badges:
15
+ - content: New domain
16
+ backgroundColor: blue
17
+ textColor: blue
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ The Orders domain handles all operations related to customer orders, from creation to fulfillment. This documentation provides an overview of the events and services involved in the Orders domain, helping developers and stakeholders understand the event-driven architecture.
23
+
24
+ <Admonition type="warning">Please ensure all services are updated to the latest version for compatibility and performance improvements.</Admonition>
25
+
26
+ ## Bounded context
27
+
28
+ <NodeGraph />
29
+
30
+ ### Order example (sequence diagram)
31
+
32
+ ```mermaid
33
+ sequenceDiagram
34
+ participant Customer
35
+ participant OrdersService
36
+ participant InventoryService
37
+ participant NotificationService
38
+
39
+ Customer->>OrdersService: Place Order
40
+ OrdersService->>InventoryService: Check Inventory
41
+ InventoryService-->>OrdersService: Inventory Available
42
+ OrdersService->>InventoryService: Reserve Inventory
43
+ OrdersService->>NotificationService: Send Order Confirmation
44
+ NotificationService-->>Customer: Order Confirmation
45
+ OrdersService->>Customer: Order Placed Successfully
46
+ OrdersService->>InventoryService: Update Inventory
47
+ ```
48
+
49
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ id: Orders
3
+ name: Orders
4
+ version: 0.0.1
5
+ summary: |
6
+ Domain for everything shopping
7
+ owners:
8
+ - dboyne
9
+ services:
10
+ - id: InventoryService
11
+ version: 0.0.2
12
+ badges:
13
+ - content: New domain
14
+ backgroundColor: blue
15
+ textColor: blue
16
+ ---
17
+
18
+ ## Overview
19
+
20
+ <NodeGraph />
@@ -0,0 +1,24 @@
1
+ ---
2
+ id: Payment
3
+ name: Payment
4
+ version: 0.0.2
5
+ summary: |
6
+ Domain that contains payment related services and messages.
7
+ owners:
8
+ - dboyne
9
+ services:
10
+ - id: PaymentService
11
+ version: 0.0.1
12
+ badges:
13
+ - content: Payment Domain
14
+ backgroundColor: blue
15
+ textColor: blue
16
+ ---
17
+
18
+ ## Overview
19
+
20
+ 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
21
+
22
+ ## Bounded context
23
+
24
+ <NodeGraph />
@@ -0,0 +1,18 @@
1
+ export default {
2
+ title: 'EventCatalog',
3
+ trailingSlash: false,
4
+ tagline: 'Discover, Explore and Document your Event Driven Architectures',
5
+ organizationName: 'Your Company',
6
+ homepageLink: 'https://eventcatalog.dev/',
7
+ editUrl: 'https://github.com/boyney123/eventcatalog-demo/edit/master',
8
+ logo: {
9
+ alt: 'EventCatalog Logo',
10
+ src: 'logo.svg'
11
+ },
12
+ docs: {
13
+ sidebar: {
14
+ // Should the sub heading be rendered in the docs sidebar?
15
+ showPageHeadings: true
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ /* Custom styling support coming soon */
@@ -0,0 +1,103 @@
1
+ ---
2
+ id: InventoryAdjusted
3
+ name: Inventory adjusted
4
+ version: 0.0.4
5
+ summary: |
6
+ Indicates a change in inventory level
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
+ schemaPath: 'schema.avro'
21
+ ---
22
+
23
+ ## Overview
24
+
25
+ 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.
26
+
27
+ ## Architecture diagram
28
+
29
+ <NodeGraph />
30
+
31
+ ## Payload example
32
+
33
+ Event example you my see being published.
34
+
35
+ ```json title="Payload example"
36
+ {
37
+ "Name": "John Doe",
38
+ "Age": 30,
39
+ "Department": "Engineering",
40
+ "Position": "Software Engineer",
41
+ "Salary": 85000.50,
42
+ "JoinDate": "2024-01-15"
43
+ }
44
+ ```
45
+
46
+ ## Schema (avro)
47
+
48
+ <Schema file="schema.avro" title="Inventory Adjusted Schema (avro)" />
49
+
50
+ ## Producing the Event
51
+
52
+ To produce an Inventory Adjusted event, use the following example Kafka producer configuration in Python:
53
+
54
+ ```python title="Produce event in Python" frame="terminal"
55
+ from kafka import KafkaProducer
56
+ import json
57
+ from datetime import datetime
58
+
59
+ # Kafka configuration
60
+ producer = KafkaProducer(
61
+ bootstrap_servers=['localhost:9092'],
62
+ value_serializer=lambda v: json.dumps(v).encode('utf-8')
63
+ )
64
+
65
+ # Event data
66
+ event_data = {
67
+ "event_id": "abc123",
68
+ "timestamp": datetime.utcnow().isoformat() + 'Z',
69
+ "product_id": "prod987",
70
+ "adjusted_quantity": 10,
71
+ "new_quantity": 150,
72
+ "adjustment_reason": "restock",
73
+ "adjusted_by": "user123"
74
+ }
75
+
76
+ # Send event to Kafka topic
77
+ producer.send('inventory.adjusted', event_data)
78
+ producer.flush()
79
+ ```
80
+
81
+ ### Consuming the Event
82
+
83
+ To consume an Inventory Adjusted event, use the following example Kafka consumer configuration in Python:
84
+
85
+ ```python title="Consuming the event with python" frame="terminal"
86
+ from kafka import KafkaConsumer
87
+ import json
88
+
89
+ # Kafka configuration
90
+ consumer = KafkaConsumer(
91
+ 'inventory.adjusted',
92
+ bootstrap_servers=['localhost:9092'],
93
+ auto_offset_reset='earliest',
94
+ enable_auto_commit=True,
95
+ group_id='inventory_group',
96
+ value_serializer=lambda v: json.dumps(v).encode('utf-8')
97
+ )
98
+
99
+ # Consume events
100
+ for message in consumer:
101
+ event_data = json.loads(message.value)
102
+ print(f"Received Inventory Adjusted event: {event_data}")
103
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "type" : "record",
3
+ "namespace" : "Tutorialspoint",
4
+ "name" : "Employee",
5
+ "fields" : [
6
+ { "name" : "Name", "type" : "string" },
7
+ { "name" : "Age", "type" : "int" },
8
+ { "name" : "Department", "type" : "string" },
9
+ { "name" : "Position", "type" : "string" },
10
+ { "name" : "Salary", "type" : "double" },
11
+ { "name" : "JoinDate", "type" : "string", "logicalType": "date" }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: InventoryAdjusted
3
+ name: Inventory adjusted
4
+ version: 0.0.1
5
+ summary: |
6
+ Indicates a change in inventory level
7
+ owners:
8
+ - dboyne
9
+ badges:
10
+ - content: Recently updated!
11
+ backgroundColor: green
12
+ textColor: green
13
+ ---
14
+
15
+ <Admonition>When firing this event make sure you set the `correlation-id` in the headers. Our schemas have standard metadata make sure you read and follow it.</Admonition>
16
+
17
+ ### Details
18
+
19
+ <NodeGraph />
@@ -0,0 +1,9 @@
1
+ {
2
+ "type" : "record",
3
+ "namespace" : "Tutorialspoint",
4
+ "name" : "Employee",
5
+ "fields" : [
6
+ { "name" : "Name" , "type" : "string" },
7
+ { "name" : "Age" , "type" : "int" }
8
+ ]
9
+ }
@@ -0,0 +1,104 @@
1
+ ---
2
+ id: InventoryAdjusted
3
+ name: Inventory adjusted
4
+ version: 0.0.3
5
+ summary: |
6
+ Indicates a change in inventory level
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
+ ## Event Details
29
+
30
+ ### Event Name
31
+ `inventory.adjusted`
32
+
33
+ ### Description
34
+ This event indicates that the inventory count for one or more products has been adjusted. The event carries the updated inventory details including the product ID, the new quantity, and the reason for the adjustment.
35
+
36
+ ### Payload
37
+ The payload of the `Inventory Adjusted` event includes the following fields:
38
+
39
+ ```json title="Example of payload" frame="terminal"
40
+ {
41
+ "event_id": "string",
42
+ "timestamp": "ISO 8601 date-time",
43
+ "product_id": "string",
44
+ "adjusted_quantity": "integer",
45
+ "new_quantity": "integer",
46
+ "adjustment_reason": "string",
47
+ "adjusted_by": "string"
48
+ }
49
+ ```
50
+
51
+ ### Producing the Event
52
+
53
+ To produce an Inventory Adjusted event, use the following example Kafka producer configuration in Python:
54
+
55
+ ```python title="Produce event in Python" frame="terminal"
56
+ from kafka import KafkaProducer
57
+ import json
58
+ from datetime import datetime
59
+
60
+ # Kafka configuration
61
+ producer = KafkaProducer(
62
+ bootstrap_servers=['localhost:9092'],
63
+ value_serializer=lambda v: json.dumps(v).encode('utf-8')
64
+ )
65
+
66
+ # Event data
67
+ event_data = {
68
+ "event_id": "abc123",
69
+ "timestamp": datetime.utcnow().isoformat() + 'Z',
70
+ "product_id": "prod987",
71
+ "adjusted_quantity": 10,
72
+ "new_quantity": 150,
73
+ "adjustment_reason": "restock",
74
+ "adjusted_by": "user123"
75
+ }
76
+
77
+ # Send event to Kafka topic
78
+ producer.send('inventory.adjusted', event_data)
79
+ producer.flush()
80
+ ```
81
+
82
+ ### Consuming the Event
83
+
84
+ To consume an Inventory Adjusted event, use the following example Kafka consumer configuration in Python:
85
+
86
+ ```python title="Consuming the event with python" frame="terminal"
87
+ from kafka import KafkaConsumer
88
+ import json
89
+
90
+ # Kafka configuration
91
+ consumer = KafkaConsumer(
92
+ 'inventory.adjusted',
93
+ bootstrap_servers=['localhost:9092'],
94
+ auto_offset_reset='earliest',
95
+ enable_auto_commit=True,
96
+ group_id='inventory_group',
97
+ value_serializer=lambda v: json.dumps(v).encode('utf-8')
98
+ )
99
+
100
+ # Consume events
101
+ for message in consumer:
102
+ event_data = json.loads(message.value)
103
+ print(f"Received Inventory Adjusted event: {event_data}")
104
+ ```
@@ -0,0 +1,14 @@
1
+ {
2
+ "type" : "record",
3
+ "namespace" : "Tutorialspoint",
4
+ "name" : "Employee",
5
+ "fields" : [
6
+ { "name" : "Name" , "type" : "string" },
7
+ { "name" : "Age" , "type" : "int" },
8
+ { "name" : "Age" , "type" : "int" },
9
+ { "name" : "Age" , "type" : "int" },
10
+ { "name" : "Age" , "type" : "int" },
11
+ { "name" : "Age" , "type" : "int" },
12
+ { "name" : "Age" , "type" : "int" }
13
+ ]
14
+ }