Function: writeEvent()
writeEvent(
directory): (event,options) =>Promise<void>
Defined in: events.ts:120
Write an event to EventCatalog.
You can optionally overide the path of the event.
Parameters
| Parameter | Type |
|---|---|
directory | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
event | Event |
options | { format: "md" | "mdx"; override: boolean; path: string; versionExistingContent: boolean; } |
options.format? | "md" | "mdx" |
options.override? | boolean |
options.path? | string |
options.versionExistingContent? | boolean |
Returns
Promise<void>
Example
import utils from '@eventcatalog/utils';
const { writeEvent } = utils('/path/to/eventcatalog');
// Write an event to the catalog
// Event would be written to events/InventoryAdjusted
await writeEvent({
id: 'InventoryAdjusted',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
});
// Write an event to the catalog but override the path
// Event would be written to events/Inventory/InventoryAdjusted
await writeEvent({
id: 'InventoryAdjusted',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { path: "/Inventory/InventoryAdjusted"});
// Write a event to the catalog and override the existing content (if there is any)
await writeEvent({
id: 'InventoryAdjusted',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { override: true });
// Write a event to the catalog and version the previous version
// only works if the new version is greater than the previous version
await writeEvent({
id: 'InventoryAdjusted',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { versionExistingContent: true });