@eventcatalog/core 4.12.0-beta.9 → 4.12.1
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/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/{chunk-GNFKUOXD.js → chunk-DZZDBFUM.js} +1 -1
- package/dist/{chunk-K3DWGBGQ.js → chunk-EVXNBTRA.js} +1 -1
- package/dist/{chunk-YOIPWS7L.js → chunk-HH6GPY4H.js} +1 -1
- package/dist/{chunk-UIHG2TPV.js → chunk-HHZFKWX7.js} +1 -1
- package/dist/{chunk-4S47JELQ.js → chunk-UWSBZYF5.js} +3 -3
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/docs/development/01-getting-started/develop-and-build.md +18 -0
- package/dist/docs/development/ask-your-architecture/02-eventcatalog-assistant/02-configuration.md +4 -0
- package/dist/docs/development/components/components/27-code-group.md +95 -0
- package/dist/docs/development/components/components/28-columns.md +115 -0
- package/dist/docs/development/customization/05-custom-pages-and-api-routes/02-create-a-custom-page.md +21 -0
- package/dist/docs/development/customization/05-custom-pages-and-api-routes/04-reference.md +24 -0
- package/dist/docs/development/deployment/hosting-options.md +8 -0
- package/dist/docs/development/guides/resources/messages/09-add-usage-examples.md +103 -9
- package/dist/docs/development/guides/resources/schemas/04-explore-schemas/01-schema-explorer.md +79 -13
- package/dist/docs/development/upgrading/upgrading.md +8 -3
- package/dist/docs/development/upgrading/v4.md +1 -1
- package/dist/eventcatalog.cjs +1 -1
- package/dist/eventcatalog.js +12 -12
- package/dist/federation/federate.js +3 -3
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/runtime-dependencies/manifest.json +1 -3
- package/dist/runtime-dependencies/set-cookie-parser.mjs +3 -0
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/eventcatalog/auth.config.ts +3 -4
- package/eventcatalog/src/components/Header.astro +101 -33
- package/eventcatalog/src/enterprise/auth/[...auth].ts +1 -1
- package/eventcatalog/src/enterprise/auth/login.astro +2 -2
- package/eventcatalog/src/enterprise/auth/middleware/middleware-auth.ts +1 -1
- package/eventcatalog/src/utils/auth-astro/client.ts +89 -0
- package/eventcatalog/src/utils/auth-astro/config.ts +24 -0
- package/eventcatalog/src/utils/auth-astro/server.ts +74 -0
- package/package.json +3 -2
- package/dist/runtime-dependencies/auth-astro.mjs +0 -3
- package/dist/runtime-dependencies/auth-astro__client.mjs +0 -3
- package/dist/runtime-dependencies/auth-astro__server.mjs +0 -3
- package/dist/{chunk-U4YJSTGV.js → chunk-WRLNLWPW.js} +7 -7
|
@@ -176,7 +176,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
176
176
|
var import_os = __toESM(require("os"), 1);
|
|
177
177
|
|
|
178
178
|
// package.json
|
|
179
|
-
var version = "4.12.
|
|
179
|
+
var version = "4.12.1";
|
|
180
180
|
|
|
181
181
|
// src/constants.ts
|
|
182
182
|
var VERSION = version;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-UWSBZYF5.js";
|
|
4
|
+
import "../chunk-HH6GPY4H.js";
|
|
4
5
|
import "../chunk-ZAZHAVKB.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-UIHG2TPV.js";
|
|
6
|
+
import "../chunk-HHZFKWX7.js";
|
|
7
7
|
import "../chunk-RFIXKATC.js";
|
|
8
8
|
export {
|
|
9
9
|
log_build_default as default
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
raiseEvent
|
|
3
|
+
} from "./chunk-HH6GPY4H.js";
|
|
1
4
|
import {
|
|
2
5
|
countResources,
|
|
3
6
|
hashCatalogContent,
|
|
4
7
|
serializeCounts
|
|
5
8
|
} from "./chunk-ZAZHAVKB.js";
|
|
6
|
-
import {
|
|
7
|
-
raiseEvent
|
|
8
|
-
} from "./chunk-YOIPWS7L.js";
|
|
9
9
|
import {
|
|
10
10
|
getEventCatalogConfigFile,
|
|
11
11
|
verifyRequiredFieldsAreInCatalogConfigFile
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
|
@@ -24,6 +24,24 @@ npm run dev
|
|
|
24
24
|
```
|
|
25
25
|
If all goes well, EventCatalog will now be serving your project on http://localhost:3000/. Visit that link in your browser and see your new site!
|
|
26
26
|
|
|
27
|
+
### Clear the development cache
|
|
28
|
+
|
|
29
|
+
<AddedIn version="4.12.0" />
|
|
30
|
+
|
|
31
|
+
EventCatalog runs directly in your project and keeps generated files, such as content caches, types, and runtime metadata, in the `.astro/` folder.
|
|
32
|
+
|
|
33
|
+
If the development server shows stale content, start it with `--force-recreate`. This clears and regenerates the whole `.astro/` folder.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx eventcatalog dev --force-recreate
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Keep `.astro/` in your `.gitignore` and `.dockerignore` files. New catalogs created with `create-eventcatalog` include it in both.
|
|
40
|
+
|
|
41
|
+
:::info Upgrading from an older version?
|
|
42
|
+
Before 4.12, EventCatalog copied itself into a `.eventcatalog-core/` folder in your project. EventCatalog no longer creates this folder. Once any older EventCatalog processes have stopped, you can delete it. `eventcatalog dev` and `eventcatalog build` tell you when the folder is safe to delete.
|
|
43
|
+
:::
|
|
44
|
+
|
|
27
45
|
## Build and preview your catalog
|
|
28
46
|
|
|
29
47
|
To check the version of your site that will be created at build time, quit the dev server (Ctrl + C) and run the appropriate build command in your terminal:
|
package/dist/docs/development/ask-your-architecture/02-eventcatalog-assistant/02-configuration.md
CHANGED
|
@@ -52,6 +52,10 @@ _Example of installing the OpenAI model:_
|
|
|
52
52
|
npm install @ai-sdk/openai
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
:::info AI SDK version
|
|
56
|
+
From EventCatalog 4.12, the assistant uses [AI SDK v7](https://ai-sdk.dev/). Install a provider package that supports AI SDK v7, for example `@ai-sdk/openai@^4`. If you have [custom tools](/docs/development/ask-your-architecture/eventcatalog-assistant/bring-your-own-tools) that use AI SDK v6 APIs, update them to the v7 equivalents.
|
|
57
|
+
:::
|
|
58
|
+
|
|
55
59
|
#### Configuring `eventcatalog.chat.js`
|
|
56
60
|
|
|
57
61
|
This file will provide the model and any model configuration to EventCatalog.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 7.1
|
|
3
|
+
keywords:
|
|
4
|
+
- components
|
|
5
|
+
- code group
|
|
6
|
+
- code examples
|
|
7
|
+
sidebar_label: CodeGroup
|
|
8
|
+
title: CodeGroup
|
|
9
|
+
description: Show the same code example in several languages or files
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
import AddedIn from '@site/src/components/MDX/AddedIn';
|
|
13
|
+
|
|
14
|
+
<AddedIn version="4.11.0"/>
|
|
15
|
+
|
|
16
|
+
The `<CodeGroup />` component groups several fenced code blocks into one panel. Readers switch between them with tabs or a dropdown, and copy the one they need.
|
|
17
|
+
|
|
18
|
+
Use it when the same example exists in more than one language, or when an example is split across several files.
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**Example**
|
|
23
|
+
|
|
24
|
+
Wrap your code blocks in `<CodeGroup>`. The text after the language becomes the label for each block.
|
|
25
|
+
|
|
26
|
+
````mdx title="/events/OrderCreated/index.mdx"
|
|
27
|
+
<CodeGroup>
|
|
28
|
+
|
|
29
|
+
```ts publish.ts
|
|
30
|
+
await client.publish('OrderCreated', order);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```python publish.py
|
|
34
|
+
client.publish("OrderCreated", order)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</CodeGroup>
|
|
38
|
+
````
|
|
39
|
+
|
|
40
|
+
Leave a blank line after the opening tag and before the closing tag, so the code blocks are parsed as Markdown.
|
|
41
|
+
|
|
42
|
+
### Output
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
### Labels
|
|
47
|
+
|
|
48
|
+
Each code block needs a label. EventCatalog picks it in this order:
|
|
49
|
+
|
|
50
|
+
1. A `title` in the code fence, for example ` ```ts title="publish.ts" `
|
|
51
|
+
1. The first word after the language, for example ` ```ts publish.ts `
|
|
52
|
+
1. The language, for example `ts`
|
|
53
|
+
|
|
54
|
+
EventCatalog also shows an icon for the language of each block, for example TypeScript, Python, Java, Go, C#, or JSON.
|
|
55
|
+
|
|
56
|
+
When a reader picks a block, every other code group on the page with a block of the same label switches too. If a page has several examples that each include `publish.py`, choosing Python once shows Python everywhere.
|
|
57
|
+
|
|
58
|
+
### Use a dropdown
|
|
59
|
+
|
|
60
|
+
Tabs work well for two or three blocks. For more, add `dropdown` to show a language picker instead.
|
|
61
|
+
|
|
62
|
+
````mdx title="/events/OrderCreated/index.mdx"
|
|
63
|
+
<CodeGroup dropdown>
|
|
64
|
+
|
|
65
|
+
```javascript publish-order.js
|
|
66
|
+
await client.publish("OrderCreated", order);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```python publish_order.py
|
|
70
|
+
client.publish("OrderCreated", order)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```java PublishOrder.java
|
|
74
|
+
client.publish("OrderCreated", order);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```csharp PublishOrder.cs
|
|
78
|
+
await client.PublishAsync("OrderCreated", order);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
</CodeGroup>
|
|
82
|
+
````
|
|
83
|
+
|
|
84
|
+
### Props
|
|
85
|
+
|
|
86
|
+
| Prop | Type | Default | Description |
|
|
87
|
+
| ---- | ---- | ------- | ----------- |
|
|
88
|
+
| `dropdown` | `boolean` | `false` | Show a dropdown to switch between code blocks instead of tabs. |
|
|
89
|
+
| `className` | `string` | | Extra CSS classes for the group. |
|
|
90
|
+
|
|
91
|
+
### Support
|
|
92
|
+
|
|
93
|
+
The `<CodeGroup />` component is supported in domains, systems, services, all messages, flows, changelogs, custom documentation pages, and [message usage examples](/docs/development/guides/resources/messages/add-usage-examples).
|
|
94
|
+
|
|
95
|
+
Pair it with [`<Columns />`](/docs/development/components/components/columns) to show code next to the text that explains it.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 7.2
|
|
3
|
+
keywords:
|
|
4
|
+
- components
|
|
5
|
+
- columns
|
|
6
|
+
- layout
|
|
7
|
+
sidebar_label: Columns
|
|
8
|
+
title: Columns
|
|
9
|
+
description: Place content side by side in your EventCatalog pages
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
import AddedIn from '@site/src/components/MDX/AddedIn';
|
|
13
|
+
|
|
14
|
+
<AddedIn version="4.11.0"/>
|
|
15
|
+
|
|
16
|
+
The `<Columns />` component places content side by side. Each `<Column />` inside it is one column.
|
|
17
|
+
|
|
18
|
+
A common use is to put an explanation on the left and the code it describes on the right.
|
|
19
|
+
|
|
20
|
+
**Example**
|
|
21
|
+
|
|
22
|
+
````mdx title="/events/OrderCreated/index.mdx"
|
|
23
|
+
<Columns cols={2}>
|
|
24
|
+
|
|
25
|
+
<Column>
|
|
26
|
+
|
|
27
|
+
## Publish a review
|
|
28
|
+
|
|
29
|
+
Publish the event after the review is stored.
|
|
30
|
+
|
|
31
|
+
</Column>
|
|
32
|
+
|
|
33
|
+
<Column>
|
|
34
|
+
|
|
35
|
+
<CodeGroup>
|
|
36
|
+
|
|
37
|
+
```ts publish.ts
|
|
38
|
+
await client.publish('ReviewSubmitted', review);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```python publish.py
|
|
42
|
+
client.publish("ReviewSubmitted", review)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</CodeGroup>
|
|
46
|
+
|
|
47
|
+
</Column>
|
|
48
|
+
|
|
49
|
+
</Columns>
|
|
50
|
+
````
|
|
51
|
+
|
|
52
|
+
Leave a blank line after each opening tag and before each closing tag, so the content inside is parsed as Markdown.
|
|
53
|
+
|
|
54
|
+
### Output
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
### Set the column widths
|
|
59
|
+
|
|
60
|
+
By default, every column has the same width. Use `ratio` to change that. The ratio needs one number per column.
|
|
61
|
+
|
|
62
|
+
```mdx title="/events/OrderCreated/index.mdx"
|
|
63
|
+
<Columns cols={2} ratio="2:1">
|
|
64
|
+
|
|
65
|
+
<Column>
|
|
66
|
+
|
|
67
|
+
This column is twice as wide as the next one.
|
|
68
|
+
|
|
69
|
+
</Column>
|
|
70
|
+
|
|
71
|
+
<Column>
|
|
72
|
+
|
|
73
|
+
This column is narrower.
|
|
74
|
+
|
|
75
|
+
</Column>
|
|
76
|
+
|
|
77
|
+
</Columns>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If the ratio does not match the number of columns, EventCatalog uses equal widths.
|
|
81
|
+
|
|
82
|
+
### Keep a column in view
|
|
83
|
+
|
|
84
|
+
Add `sticky` to a column to keep it in view while the reader scrolls past a longer column next to it. This is useful for long explanations next to a short code sample.
|
|
85
|
+
|
|
86
|
+
```mdx
|
|
87
|
+
<Column sticky>
|
|
88
|
+
|
|
89
|
+
...
|
|
90
|
+
|
|
91
|
+
</Column>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
On narrow screens, columns stack on top of each other and `sticky` has no effect.
|
|
95
|
+
|
|
96
|
+
### Props
|
|
97
|
+
|
|
98
|
+
**`<Columns />`**
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Default | Description |
|
|
101
|
+
| ---- | ---- | ------- | ----------- |
|
|
102
|
+
| `cols` | `number` | `2` | Number of columns, from 1 to 4. |
|
|
103
|
+
| `ratio` | `string` | | Relative column widths, for example `"2:1"` or `"1:2:1"`. |
|
|
104
|
+
| `className` | `string` | | Extra CSS classes for the columns. |
|
|
105
|
+
|
|
106
|
+
**`<Column />`**
|
|
107
|
+
|
|
108
|
+
| Prop | Type | Default | Description |
|
|
109
|
+
| ---- | ---- | ------- | ----------- |
|
|
110
|
+
| `sticky` | `boolean` | `false` | Keep the column in view while the page scrolls. |
|
|
111
|
+
| `className` | `string` | | Extra CSS classes for the column. |
|
|
112
|
+
|
|
113
|
+
### Support
|
|
114
|
+
|
|
115
|
+
The `<Columns />` component is supported in domains, systems, services, all messages, flows, changelogs, custom documentation pages, and [message usage examples](/docs/development/guides/resources/messages/add-usage-examples).
|
|
@@ -10,6 +10,7 @@ description: Add a custom Astro page to your EventCatalog.
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
import ProjectTree from '@site/src/components/MDX/ProjectTree';
|
|
13
|
+
import AddedIn from '@site/src/components/MDX/AddedIn';
|
|
13
14
|
|
|
14
15
|
This guide shows you how to add a custom page to your catalog.
|
|
15
16
|
|
|
@@ -172,6 +173,26 @@ const { id } = Astro.params;
|
|
|
172
173
|
|
|
173
174
|
This page is available at `/custom/reports/:id`, for example `/custom/reports/orders`.
|
|
174
175
|
|
|
176
|
+
## Render a full-width page
|
|
177
|
+
|
|
178
|
+
<AddedIn version="4.12.0" />
|
|
179
|
+
|
|
180
|
+
Custom pages get the same page padding as built-in pages. If your page needs the full width, for example a dashboard, pass `fullWidth` to the layout.
|
|
181
|
+
|
|
182
|
+
```js title="pages/dashboard.astro"
|
|
183
|
+
---
|
|
184
|
+
import Layout from '@catalog/layouts/Layout.astro';
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
<Layout title="Dashboard" fullWidth>
|
|
188
|
+
<div class="h-full w-full">
|
|
189
|
+
<!-- Your full-width content -->
|
|
190
|
+
</div>
|
|
191
|
+
</Layout>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
See the [`Layout` props](/docs/development/customization/custom-pages-and-api-routes/reference#layout-props) for all options.
|
|
195
|
+
|
|
175
196
|
## Learn more
|
|
176
197
|
|
|
177
198
|
Custom pages follow Astro's routing model. See the [Astro pages documentation](https://docs.astro.build/en/basics/astro-pages/) if you want to go deeper.
|
|
@@ -103,6 +103,30 @@ Use these aliases in custom pages.
|
|
|
103
103
|
| `@catalog/utils` | Stable catalog data helpers such as `getServices`, `getDomains`, and `getEvents`. |
|
|
104
104
|
| `@catalog/components/*` | Components from your catalog's top-level `components` directory. |
|
|
105
105
|
|
|
106
|
+
## `Layout` props
|
|
107
|
+
|
|
108
|
+
`@catalog/layouts/Layout.astro` accepts these props.
|
|
109
|
+
|
|
110
|
+
```js title="pages/reports.astro"
|
|
111
|
+
---
|
|
112
|
+
import Layout from '@catalog/layouts/Layout.astro';
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
<Layout title="Service reports" description="Operational views built from catalog data." sidebar={false}>
|
|
116
|
+
<h1>Service reports</h1>
|
|
117
|
+
</Layout>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Prop | Type | Default | Description |
|
|
121
|
+
| --- | --- | --- | --- |
|
|
122
|
+
| `title` | `string` | | Page title. Required. |
|
|
123
|
+
| `description` | `string` | | Page description used in the page metadata. |
|
|
124
|
+
| `sidebar` | `boolean` | `true` | Show the resource sidebar (domains, services, messages). |
|
|
125
|
+
| `showHeader` | `boolean` | `true` | Show the EventCatalog header (search and navigation). |
|
|
126
|
+
| `fullWidth` | `boolean` | `false` | Render content edge-to-edge without EventCatalog's page padding. Added in 4.12.0. |
|
|
127
|
+
|
|
128
|
+
By default, custom pages get the same page padding and theme text color as built-in pages, so they read well in light and dark mode. Set `fullWidth` when your page controls its own layout, for example a dashboard or an embedded tool. Full-width pages still inherit the theme text color.
|
|
129
|
+
|
|
106
130
|
## `@catalog/utils`
|
|
107
131
|
|
|
108
132
|
Use `@catalog/utils` to read catalog resources from custom pages and API routes.
|
|
@@ -102,6 +102,14 @@ Then you can run the server with:
|
|
|
102
102
|
docker run -p 3000:3000 eventcatalog-server
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
:::warning Your `.env` file is included in the server image
|
|
106
|
+
|
|
107
|
+
`COPY . .` copies your `.env` file into the image, so EventCatalog can read your license key and other keys (for example `OPENAI_API_KEY`) during the build and when the server runs.
|
|
108
|
+
|
|
109
|
+
Anyone who can pull the image can read these keys. Only push the image to a private registry, and do not share it publicly.
|
|
110
|
+
|
|
111
|
+
:::
|
|
112
|
+
|
|
105
113
|
:::info "Why do I need a server to run EventCatalog?"
|
|
106
114
|
|
|
107
115
|
Some features of EventCatalog require a server to run (e.g. [EventCatalog Chat](/features/ai-assistant) and [EventCatalog Authentication](/docs/development/authentication/introduction)).
|
|
@@ -13,16 +13,16 @@ sidebar_position: 7
|
|
|
13
13
|
import AddedIn from '@site/src/components/MDX/AddedIn';
|
|
14
14
|
import ProjectTree from '@site/src/components/MDX/ProjectTree';
|
|
15
15
|
|
|
16
|
-
EventCatalog lets you attach
|
|
16
|
+
EventCatalog lets you attach examples to any message (event, command, or query). This can help your team understand exactly how your schemas can be used
|
|
17
17
|
in your architecture and provide them with real examples.
|
|
18
18
|
|
|
19
|
-
Examples appear in the Schema Explorer under
|
|
19
|
+
Examples appear in the [Schema Explorer](/docs/development/guides/resources/schemas/explore-schemas/schema-explorer) under an **Examples** tab alongside the schema, properties, and version tabs.
|
|
20
20
|
|
|
21
|
-

|
|
22
22
|
|
|
23
23
|
### Add examples
|
|
24
24
|
|
|
25
|
-
Create an `examples/` folder inside your message directory and drop in any example files. EventCatalog supports any text-based format: JSON, YAML, XML, Protobuf, and more.
|
|
25
|
+
Create an `examples/` folder inside your message directory and drop in any example files. EventCatalog supports any text-based format: JSON, YAML, XML, Protobuf, Markdown, MDX, and more.
|
|
26
26
|
|
|
27
27
|
<ProjectTree
|
|
28
28
|
items={[
|
|
@@ -54,7 +54,99 @@ Create an `examples/` folder inside your message directory and drop in any examp
|
|
|
54
54
|
]}
|
|
55
55
|
/>
|
|
56
56
|
|
|
57
|
-
The **
|
|
57
|
+
The **Examples** tab appears automatically when at least one example file is present. No frontmatter changes are required.
|
|
58
|
+
|
|
59
|
+
All examples for a message are shown on the same tab, one after another, ordered by file path.
|
|
60
|
+
|
|
61
|
+
### Write examples in Markdown or MDX
|
|
62
|
+
|
|
63
|
+
<AddedIn version="4.11.0" />
|
|
64
|
+
|
|
65
|
+
Raw payloads show consumers the shape of a message, but not how to use it. Write your examples in Markdown or MDX to explain the scenario, call out important fields, and show code in more than one language.
|
|
66
|
+
|
|
67
|
+
<ProjectTree
|
|
68
|
+
items={[
|
|
69
|
+
{
|
|
70
|
+
name: 'OrderCreated',
|
|
71
|
+
type: 'folder',
|
|
72
|
+
defaultOpen: true,
|
|
73
|
+
children: [
|
|
74
|
+
{ name: 'index.mdx' },
|
|
75
|
+
{ name: 'schema.json' },
|
|
76
|
+
{
|
|
77
|
+
name: 'examples',
|
|
78
|
+
type: 'folder',
|
|
79
|
+
defaultOpen: true,
|
|
80
|
+
children: [{ name: 'index.mdx', highlight: true }],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
]}
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
Markdown and MDX examples are rendered as documentation, not as source code. Use [`<Columns />`](/docs/development/components/components/columns) to put the explanation next to the code, and [`<CodeGroup />`](/docs/development/components/components/code-group) to show the same example in several languages.
|
|
88
|
+
|
|
89
|
+
:::info Other components
|
|
90
|
+
On the schema page (`/schemas/{type}/{id}/{version}`), MDX examples can use any EventCatalog [component](/docs/components/list). The preview panel on the `/schemas/explorer` list only supports `<Columns />`, `<Column />`, and `<CodeGroup />`, and shows MDX examples that use other components as source.
|
|
91
|
+
:::
|
|
92
|
+
|
|
93
|
+
````mdx title="events/OrderCreated/examples/index.mdx"
|
|
94
|
+
---
|
|
95
|
+
summary: Publish OrderCreated from checkout.
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
<Columns cols={2}>
|
|
99
|
+
|
|
100
|
+
<Column>
|
|
101
|
+
|
|
102
|
+
## Publish a single-item order
|
|
103
|
+
|
|
104
|
+
Publish an order containing one T-shirt after checkout succeeds.
|
|
105
|
+
|
|
106
|
+
### Payload details
|
|
107
|
+
|
|
108
|
+
- `orderId` identifies the order; `customerId` identifies the customer.
|
|
109
|
+
- `total` uses integer minor units; `currency` is `GBP`.
|
|
110
|
+
|
|
111
|
+
</Column>
|
|
112
|
+
|
|
113
|
+
<Column>
|
|
114
|
+
|
|
115
|
+
<CodeGroup dropdown>
|
|
116
|
+
|
|
117
|
+
```javascript publish-order.js
|
|
118
|
+
await client.publish("OrderCreated", {
|
|
119
|
+
orderId: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
|
|
120
|
+
total: 4999,
|
|
121
|
+
currency: "GBP",
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```python publish_order.py
|
|
126
|
+
client.publish("OrderCreated", {
|
|
127
|
+
"orderId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
|
|
128
|
+
"total": 4999,
|
|
129
|
+
"currency": "GBP",
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
</CodeGroup>
|
|
134
|
+
|
|
135
|
+
</Column>
|
|
136
|
+
|
|
137
|
+
</Columns>
|
|
138
|
+
````
|
|
139
|
+
|
|
140
|
+
Markdown and MDX examples support these frontmatter fields. Both are optional.
|
|
141
|
+
|
|
142
|
+
| Field | Type | Description |
|
|
143
|
+
| ----- | ---- | ----------- |
|
|
144
|
+
| `title` | `string` | Title for the example. When omitted, EventCatalog uses the first level-one heading, then the file name. |
|
|
145
|
+
| `summary` | `string` | Short description shown above the example. |
|
|
146
|
+
|
|
147
|
+
:::tip
|
|
148
|
+
You can put every example in a single `examples/index.mdx` file, or split them across several files. Use a horizontal rule (`---`) between examples in the same file to separate them.
|
|
149
|
+
:::
|
|
58
150
|
|
|
59
151
|
### Organise with subfolders
|
|
60
152
|
|
|
@@ -105,13 +197,15 @@ international-order.json:
|
|
|
105
197
|
summary: An order with international shipping and customs information.
|
|
106
198
|
```
|
|
107
199
|
|
|
108
|
-
All fields are optional. When `name` is omitted, EventCatalog uses the filename without its extension
|
|
200
|
+
All fields are optional. When `name` is omitted, EventCatalog uses the filename without its extension.
|
|
109
201
|
|
|
110
202
|
| Field | Type | Description |
|
|
111
203
|
| ----- | ---- | ----------- |
|
|
112
|
-
| `name` | `string` | Display name
|
|
113
|
-
| `summary` | `string` | Short description shown
|
|
114
|
-
| `usage` | `string` | How-to-run snippet shown below the
|
|
204
|
+
| `name` | `string` | Display name for the example |
|
|
205
|
+
| `summary` | `string` | Short description shown above the example |
|
|
206
|
+
| `usage` | `string` | How-to-run snippet shown below the example |
|
|
207
|
+
|
|
208
|
+
For Markdown and MDX examples, you can use frontmatter instead of the config file. Values in `examples.config.yaml` take precedence.
|
|
115
209
|
|
|
116
210
|
### Use the SDK
|
|
117
211
|
|