Function: writeDomain()
writeDomain(
directory): (domain,options) =>Promise<void>
Defined in: domains.ts:120
Write a domain to EventCatalog.
You can optionally overide the path of the domain.
Parameters
| Parameter | Type |
|---|---|
directory | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
domain | Domain |
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 { writeDomain } = utils('/path/to/eventcatalog');
// Write a domain
// Domain would be written to domains/Payment
await writeDomain({
id: 'Payment',
name: 'Payment domain',
version: '0.0.1',
summary: 'Domain for all things to do with payments',
markdown: '# Hello world',
});
// Write a domain to the catalog but override the path
// Domain would be written to domains/Inventory/Payment
await writeDomain({
id: 'Payment',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { path: "/Inventory/Payment"});
// Write a domain to the catalog and override the existing content (if there is any)
await writeDomain({
id: 'Payment',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { override: true });
// Write a domain to the catalog and version the previous version
// only works if the new version is greater than the previous version
await writeDomain({
id: 'Payment',
name: 'Inventory Adjusted',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { versionExistingContent: true });