Skip to main content

writeDomain

Callable

  • writeDomain(directory: string): (domain: Domain, options?: { override?: boolean; path?: string; versionExistingContent?: boolean }) => Promise<void>

  • Write a domain to EventCatalog.

    You can optionally overide the path of the domain.

    @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 });